File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ @ChildContent
2+
3+ @code
4+ {
5+ [Parameter ]
6+ public RenderFragment ChildContent { get ; set ; }
7+ }
Original file line number Diff line number Diff line change 1+ @inherits TestComponentBase
2+
3+ <Fixture Test =" HelloWorldTest" >
4+ <ComponentUnderTest >
5+ <Wrapper >
6+ <HelloWorld />
7+ </Wrapper >
8+ </ComponentUnderTest >
9+
10+ @code
11+ {
12+ void HelloWorldTest (Fixture fixture )
13+ {
14+ var cut = fixture .GetComponentUnderTest <HelloWorld >();
15+ }
16+ }
17+ </Fixture >
Original file line number Diff line number Diff line change 1+ using Xunit ;
2+ using Bunit ;
3+ using System . Collections . Generic ;
4+ using Microsoft . AspNetCore . Components ;
5+ using Microsoft . AspNetCore . Components . Web ;
6+
7+ using static Bunit . ComponentParameterFactory ;
8+
9+ namespace Bunit . Docs . Samples
10+ {
11+ public class NestedComponentTest
12+ {
13+ [ Fact ]
14+ public void NestedComponent ( )
15+ {
16+ using var ctx = new TestContext ( ) ;
17+
18+ // Using C# factory methods
19+ var wrapper1 = ctx . RenderComponent < Wrapper > (
20+ ChildContent < HelloWorld > ( )
21+ ) ;
22+ var cut1 = wrapper1 . FindComponent < HelloWorld > ( ) ;
23+
24+ // Using parameter builder
25+ var wrapper2 = ctx . RenderComponent < Wrapper > ( parameters => parameters
26+ . AddChildContent < HelloWorld > ( )
27+ ) ;
28+ var cut2 = wrapper2 . FindComponent < HelloWorld > ( ) ;
29+ }
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments