Skip to content

Commit 7168943

Browse files
committed
Updates docs with guide for using render tree property
1 parent 424c1ce commit 7168943

File tree

14 files changed

+104
-13
lines changed

14 files changed

+104
-13
lines changed

docs/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ trim_trailing_whitespace = false
1010

1111
[*.{cs,razor}]
1212
tab_size = 2
13+
indent_style = space
1314
dotnet_diagnostic.BL0001.severity = none
1415
dotnet_diagnostic.BL0002.severity = none
1516
dotnet_diagnostic.BL0003.severity = none
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Cascading value: @Value
2+
@code
3+
{
4+
[CascadingParameter]
5+
public string Value { get; set; }
6+
}

docs/samples/tests/mstest/BunitTestContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Bunit.Docs.Samples
88
{
9-
public abstract class BunitTestContext : ITestContext, IDisposable
9+
public abstract class BunitTestContext : IDisposable
1010
{
1111
private Bunit.TestContext _context;
1212

docs/samples/tests/nunit/BunitTestContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Bunit.Docs.Samples
88
{
9-
public abstract class BunitTestContext : ITestContext, IDisposable
9+
public abstract class BunitTestContext : IDisposable
1010
{
1111
private Bunit.TestContext _context;
1212

docs/samples/tests/razor/_Imports.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
@using Microsoft.Extensions.DependencyInjection
99
@using AngleSharp.Dom
1010
@using Bunit
11-
@using Bunit.TestDoubles.JSInterop
11+
@using Bunit.TestDoubles
1212
@using Xunit

docs/samples/tests/xunit/InjectAuthServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Bunit.TestDoubles.Authorization;
1+
using Bunit.TestDoubles;
22
using System;
33
using Xunit;
44

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Xunit;
2+
using Bunit;
3+
using System.Collections.Generic;
4+
using Microsoft.AspNetCore.Components;
5+
using Microsoft.AspNetCore.Components.Web;
6+
using Microsoft.Extensions.DependencyInjection;
7+
8+
namespace Bunit.Docs.Samples
9+
{
10+
public class RenderTreeTest
11+
{
12+
[Fact]
13+
public void PrintCascadingValueTest()
14+
{
15+
using var ctx = new TestContext();
16+
17+
// Add a cascading value to the test contexts root render tree.
18+
ctx.RenderTree.Add<CascadingValue<string>>(parameters => parameters
19+
.Add(p => p.Value, "FOO")
20+
);
21+
22+
// The component will be rendered as a chld of last
23+
// component added to the RenderTree property.
24+
var cut = ctx.RenderComponent<PrintCascadingValue>();
25+
26+
// Verify that the cascading value was passed correctly.
27+
cut.MarkupMatches($"Cascading value: FOO");
28+
}
29+
30+
[Fact]
31+
public void PrintCascadingValue2Test()
32+
{
33+
using var ctx = new TestContext();
34+
35+
// Add a cascading value to the test contexts root render tree.
36+
ctx.RenderTree.TryAdd<CascadingValue<string>>(parameters => parameters
37+
.Add(p => p.Value, "BAR?")
38+
);
39+
40+
// The component will be rendered as a chld of last
41+
// component added to the RenderTree property.
42+
var cut = ctx.RenderComponent<PrintCascadingValue>();
43+
44+
// Verify that the cascading value was passed correctly.
45+
cut.MarkupMatches($"Cascading value: BAR?");
46+
}
47+
}
48+
}

docs/samples/tests/xunit/UserInfoTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Bunit.TestDoubles.Authorization;
1+
using Bunit.TestDoubles;
22
using Xunit;
33

44
namespace Bunit.Docs.Samples

docs/samples/tests/xunit/UserRightsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Bunit.TestDoubles.Authorization;
1+
using Bunit.TestDoubles;
22
using System.Security.Claims;
33
using System.Globalization;
44
using Xunit;

docs/samples/tests/xunit/bunit.docs.xunit.samples.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18+
<ProjectReference Include="../../../../src/bunit.core/bunit.core.csproj" />
1819
<ProjectReference Include="../../../../src/bunit.web/bunit.web.csproj" />
1920
<ProjectReference Include="../../../../src/bunit.xunit/bunit.xunit.csproj" />
2021
<ProjectReference Include="../../components/bunit.docs.samples.csproj" />

0 commit comments

Comments
 (0)