File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed
Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ <button @onclick =" ClickHandler" >Click ME!</button >
2+ @code
3+ {
4+ void ClickHandler (MouseEventArgs args )
5+ {
6+ // ...
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ @inherits TestComponentBase
2+
3+ <Fixture Test =" ClickingButtonWorks" >
4+ <ComponentUnderTest >
5+ <ClickMe />
6+ </ComponentUnderTest >
7+
8+ @code
9+ {
10+ void ClickingButtonWorks (Fixture fixture )
11+ {
12+ // Arrange
13+ var cut = fixture .GetComponentUnderTest <ClickMe >();
14+ var buttonElement = cut .Find (" button" );
15+
16+ // Act
17+ buttonElement .Click ();
18+ buttonElement .Click (detail : 3 , ctrlKey : true );
19+ buttonElement .Click (new MouseEventArgs ());
20+
21+ // Assert
22+ // ...
23+ }
24+ }
25+ </Fixture >
Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Components . Web ;
2+ using Xunit ;
3+ using Bunit ;
4+
5+ namespace Bunit . Docs . Samples
6+ {
7+ public class ClickMeTest
8+ {
9+ [ Fact ]
10+ public void ClickingButtonWorks ( )
11+ {
12+ // Arrange
13+ using var ctx = new TestContext ( ) ;
14+ var cut = ctx . RenderComponent < ClickMe > ( ) ;
15+ var buttonElement = cut . Find ( "button" ) ;
16+
17+ // Act
18+ buttonElement . Click ( ) ;
19+ buttonElement . Click ( detail : 3 , ctrlKey : true ) ;
20+ buttonElement . Click ( new MouseEventArgs ( ) ) ;
21+
22+ // Assert
23+ // ...
24+ }
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments