Skip to content

Commit 552c9cb

Browse files
committed
doc: fixes to sample code to make it compile
1 parent 8afeb76 commit 552c9cb

6 files changed

Lines changed: 32 additions & 17 deletions

File tree

docs/samples/components/bunit.docs.samples.csproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0</TargetFrameworks>
5+
<LangVersion>10.0</LangVersion>
56
<RazorLangVersion>3.0</RazorLangVersion>
67
<RootNamespace>Bunit.Docs.Samples</RootNamespace>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<NoWarn>CA1014,NU5104</NoWarn>
10+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
711
</PropertyGroup>
812

913
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
@@ -30,4 +34,12 @@
3034
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.0" />
3135
</ItemGroup>
3236

37+
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
38+
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
39+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
40+
<PackageReference Include="Microsoft.AspNetCore.Components" Version="7.0.0" />
41+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.0" />
42+
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="7.0.0" />
43+
</ItemGroup>
44+
3345
</Project>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
3+
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
44
<IsPackable>false</IsPackable>
55
<LangVersion>10.0</LangVersion>
66
<RazorLangVersion>3.0</RazorLangVersion>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<NoWarn>CA1014,NU5104</NoWarn>
9+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
710
</PropertyGroup>
811
</Project>

docs/samples/tests/xunit/HelloWorldExplicitContextRazorTest.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using var ctx = new TestContext();
88

99
// Act
10-
var cut = Render(@<HelloWorld/>);
10+
var cut = ctx.Render(@<HelloWorld/>);
1111

1212
// Assert
1313
cut.MarkupMatches(@<h1>Hello world from Blazor</h1>);

docs/samples/tests/xunit/InjectAuthServiceTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class InjectAuthServiceTest : TestContext
1010
public void Test001()
1111
{
1212
// arrange
13-
var authContext = AddTestAuthorization();
13+
var authContext = this.AddTestAuthorization();
1414
authContext.SetAuthorized("TestUserName", AuthorizationState.Authorized);
1515

1616
// act
@@ -24,7 +24,7 @@ public void Test001()
2424
public void Test002()
2525
{
2626
// arrange
27-
var authContext = AddTestAuthorization();
27+
var authContext = this.AddTestAuthorization();
2828

2929
// act
3030
var cut = RenderComponent<InjectAuthService>();

docs/samples/tests/xunit/UserInfoTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class UserInfoTest : TestContext
99
public void Test001()
1010
{
1111
// Arrange
12-
AddTestAuthorization();
12+
this.AddTestAuthorization();
1313

1414
// Act
1515
var cut = RenderComponent<UserInfo>();
@@ -23,7 +23,7 @@ public void Test001()
2323
public void Test004()
2424
{
2525
// Arrange
26-
var authContext = AddTestAuthorization();
26+
var authContext = this.AddTestAuthorization();
2727
authContext.SetAuthorizing();
2828

2929
// Act
@@ -38,7 +38,7 @@ public void Test004()
3838
public void Test002()
3939
{
4040
// Arrange
41-
var authContext = AddTestAuthorization();
41+
var authContext = this.AddTestAuthorization();
4242
authContext.SetAuthorized("TEST USER", AuthorizationState.Unauthorized);
4343

4444
// Act
@@ -53,7 +53,7 @@ public void Test002()
5353
public void Test003()
5454
{
5555
// Arrange
56-
var authContext = AddTestAuthorization();
56+
var authContext = this.AddTestAuthorization();
5757
authContext.SetAuthorized("TEST USER");
5858

5959
// Act

docs/samples/tests/xunit/UserRightsTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class UserRightsTest : TestContext
1111
public void Test001()
1212
{
1313
// Arrange
14-
var authContext = AddTestAuthorization();
14+
var authContext = this.AddTestAuthorization();
1515
authContext.SetAuthorized("TEST USER");
1616

1717
// Act
@@ -26,7 +26,7 @@ public void Test001()
2626
public void Test002()
2727
{
2828
// Arrange
29-
var authContext = AddTestAuthorization();
29+
var authContext = this.AddTestAuthorization();
3030
authContext.SetAuthorized("TEST USER");
3131
authContext.SetRoles("superuser");
3232

@@ -44,7 +44,7 @@ public void Test002()
4444
public void Test003()
4545
{
4646
// Arrange
47-
var authContext = AddTestAuthorization();
47+
var authContext = this.AddTestAuthorization();
4848
authContext.SetAuthorized("TEST USER");
4949
authContext.SetRoles("admin", "superuser");
5050

@@ -63,7 +63,7 @@ public void Test003()
6363
public void Test004()
6464
{
6565
// Arrange
66-
var authContext = AddTestAuthorization();
66+
var authContext = this.AddTestAuthorization();
6767
authContext.SetAuthorized("TEST USER");
6868
authContext.SetPolicies("content-editor");
6969

@@ -81,7 +81,7 @@ public void Test004()
8181
public void Test0041()
8282
{
8383
// Arrange
84-
var authContext = AddTestAuthorization();
84+
var authContext = this.AddTestAuthorization();
8585
authContext.SetAuthorized("TEST USER");
8686
authContext.SetPolicies("content-editor", "approver");
8787

@@ -99,7 +99,7 @@ public void Test0041()
9999
public void Test006()
100100
{
101101
// Arrange
102-
var authContext = AddTestAuthorization();
102+
var authContext = this.AddTestAuthorization();
103103
authContext.SetAuthorized("TEST USER");
104104
authContext.SetClaims(
105105
new Claim(ClaimTypes.Email, "test@example.com"),
@@ -121,7 +121,7 @@ public void Test006()
121121
public void Test005()
122122
{
123123
// Arrange
124-
var authContext = AddTestAuthorization();
124+
var authContext = this.AddTestAuthorization();
125125
authContext.SetAuthorized("TEST USER");
126126
authContext.SetRoles("admin", "superuser");
127127
authContext.SetPolicies("content-editor");
@@ -144,7 +144,7 @@ public void Test005()
144144
public void Test007()
145145
{
146146
// Arrange
147-
var authContext = AddTestAuthorization();
147+
var authContext = this.AddTestAuthorization();
148148
authContext.SetAuthorized("TEST USER");
149149
authContext.SetAuthenticationType("custom-auth-type");
150150

0 commit comments

Comments
 (0)