Skip to content

Commit 624309b

Browse files
authored
Create CounterTestWithCtx.cs
1 parent 7072e6d commit 624309b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Xunit;
2+
using Bunit;
3+
4+
namespace Bunit.Docs.Samples
5+
{
6+
public class CounterTestWithCtx
7+
{
8+
[Fact]
9+
public void CounterShouldIncrementWhenClicked()
10+
{
11+
// Arrange: render the Counter.razor component
12+
using var ctx = new TestContext();
13+
var cut = ctx.RenderComponent<Counter>();
14+
15+
// Act: find and click the <button> element to increment
16+
// the counter in the <p> element
17+
cut.Find("button").Click();
18+
19+
// Assert: first find the <p> element, then verify its content
20+
cut.Find("p").MarkupMatches("<p>Current count: 1</p>");
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)