Skip to content

Commit 00671d1

Browse files
committed
Create the xUnit project and setup bUnit for unit testing
1 parent 4c8456f commit 00671d1

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/AKSoftware.Blazor.Utilities.sln

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AKSoftware.Blazor.Utilities
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorUtilitiesSample", "BlazorUtilitiesSample\BlazorUtilitiesSample.csproj", "{B6911471-D8E8-4661-A48F-D52160FA283A}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorUtilitiesSample.Tests", "BlazorUtilitiesSample.Tests\BlazorUtilitiesSample.Tests.csproj", "{CB03C3F0-BED8-405A-9879-4AE2BF52C969}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{B6911471-D8E8-4661-A48F-D52160FA283A}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{B6911471-D8E8-4661-A48F-D52160FA283A}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{B6911471-D8E8-4661-A48F-D52160FA283A}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{CB03C3F0-BED8-405A-9879-4AE2BF52C969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{CB03C3F0-BED8-405A-9879-4AE2BF52C969}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{CB03C3F0-BED8-405A-9879-4AE2BF52C969}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{CB03C3F0-BED8-405A-9879-4AE2BF52C969}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
11+
<PackageReference Include="xunit" Version="2.4.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
16+
<PackageReference Include="coverlet.collector" Version="3.0.2">
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
<PrivateAssets>all</PrivateAssets>
19+
</PackageReference>
20+
<PackageReference Include="bunit" Version="1.2.49" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<ProjectReference Include="..\BlazorUtilitiesSample\BlazorUtilitiesSample.csproj" />
25+
</ItemGroup>
26+
<ItemGroup>
27+
<None Remove="bunit" />
28+
</ItemGroup>
29+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Linq;
3+
using BlazorUtilitiesSample.Shared;
4+
using Bunit;
5+
using Xunit;
6+
7+
namespace BlazorUtilitiesSample.Tests
8+
{
9+
public class MessagingCenterComponents
10+
{
11+
public MessagingCenterComponents()
12+
{
13+
}
14+
15+
[Fact]
16+
public void UpdateUsername_ShouldUpdateNavMenuUsername()
17+
{
18+
var testContext = new TestContext();
19+
var navMenuComponent = testContext.RenderComponent<NavMenu>();
20+
var firstAnchor = navMenuComponent.FindAll("a")[1];
21+
firstAnchor.MarkupMatches("<span class=\"oi oi - person\" aria-hidden=\"true\" b-g4ljmjz4uk=\"\"></span> Ahmad Mozaffar");
22+
}
23+
24+
}
25+
}

0 commit comments

Comments
 (0)