File tree Expand file tree Collapse file tree
src/bunit.generators/Web.Stubs
tests/bunit.generators.tests/Web.Stub Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,8 +4,7 @@ namespace Bunit.Web.Stubs;
44
55internal static class StubAttributeGenerator
66{
7- public static string StubAttribute => @"
8- #if NET5_0_OR_GREATER
7+ public static string StubAttribute => @"#if NET5_0_OR_GREATER
98namespace Bunit;
109
1110/// <summary>
Original file line number Diff line number Diff line change 1+ using System . Reflection ;
12using Microsoft . AspNetCore . Components ;
23
34namespace Bunit . Web . Stub ;
45
56public class StubTests
67{
78 [ Fact ]
8- public void Test001 ( )
9- { }
9+ public void Stubbed_component_has_same_parameters ( )
10+ {
11+ var counterComponentStubProperties = typeof ( CounterComponentStub ) . GetProperties ( ) ;
12+
13+ foreach ( var prop in typeof ( CounterComponent ) . GetProperties ( ) )
14+ {
15+ var matchingProp = counterComponentStubProperties . FirstOrDefault ( p => p . Name == prop . Name ) ;
16+
17+ Assert . NotNull ( matchingProp ) ;
18+
19+ var isParameter = prop . GetCustomAttribute ( typeof ( ParameterAttribute ) ) is not null ;
20+ var stubIsParameter = matchingProp . GetCustomAttribute ( typeof ( ParameterAttribute ) ) is not null ;
21+ Assert . Equal ( isParameter , stubIsParameter ) ;
22+
23+ var isCascadingParameter = prop . GetCustomAttribute ( typeof ( CascadingParameterAttribute ) ) is not null ;
24+ var stubIsCascadingParameter = matchingProp . GetCustomAttribute ( typeof ( CascadingParameterAttribute ) ) is not null ;
25+ Assert . Equal ( isCascadingParameter , stubIsCascadingParameter ) ;
26+ }
27+ }
1028
1129 [ Stub ( typeof ( CounterComponentStub ) ) ]
12- public class CounterComponentStub : ComponentBase
30+ public partial class CounterComponentStub : ComponentBase
1331 {
1432 }
1533}
You can’t perform that action at this time.
0 commit comments