-
-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathCounterCSharpTests.cs
More file actions
57 lines (52 loc) · 1.45 KB
/
CounterCSharpTests.cs
File metadata and controls
57 lines (52 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace Company.BlazorTests1;
/// <summary>
/// These tests are written entirely in C#.
/// Learn more at https://bunit.dev/docs/getting-started/writing-tests.html#creating-basic-tests-in-cs-files
/// </summary>
#if (testFramework_xunit)
public class CounterCSharpTests : TestContext
#elif (testFramework_xunitv3)
// The full qualified namespace for bUnit TestContext is used here as xunit v3 also offers a TestContext class
public class CounterCSharpTests : Bunit.TestContext
#elif (testFramework_nunit)
public class CounterCSharpTests : BunitTestContext
#elif (testFramework_mstest)
[TestClass]
public class CounterCSharpTests : BunitTestContext
#endif
{
#if (testFramework_xunit)
[Fact]
#elif (testFramework_xunitv3)
[Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
[TestMethod]
#endif
public void CounterStartsAtZero()
{
// Arrange
var cut = RenderComponent<Counter>();
// Assert that content of the paragraph shows counter at zero
cut.Find("p").MarkupMatches("<p>Current count: 0</p>");
}
#if (testFramework_xunit)
[Fact]
#elif (testFramework_xunitv3)
[Fact]
#elif (testFramework_nunit)
[Test]
#elif (testFramework_mstest)
[TestMethod]
#endif
public void ClickingButtonIncrementsCounter()
{
// Arrange
var cut = RenderComponent<Counter>();
// Act - click button to increment counter
cut.Find("button").Click();
// Assert that the counter was incremented
cut.Find("p").MarkupMatches("<p>Current count: 1</p>");
}
}