-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpctationsTestBase.Example.cs
More file actions
68 lines (47 loc) · 1.68 KB
/
ExpctationsTestBase.Example.cs
File metadata and controls
68 lines (47 loc) · 1.68 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
58
59
60
61
62
63
64
65
66
67
68
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;
namespace InsonusK.Xunit.ExpectationsTest.Test;
public class ExpectationsTest_Example : ExpectationsTestBase
{
public ExpectationsTest_Example(ITestOutputHelper output, LogLevel logLevel = LogLevel.Debug) : base(output, logLevel)
{
}
[Fact]
public async void Example_of_expectation_test()
{
#region Array
Logger.LogDebug("Test ARRAY");
var expectedValue = 123;
#endregion
#region Act
Logger.LogDebug("Test ACT");
#endregion
#region Assert
Logger.LogDebug("Test ASSERT");
Expect("Expect something", () => Assert.True(true));
await ExpectTaskAsync("Expectation from Delayed Assert", async () => await DelayedAssert());
var assertedReturnValue = await ExpectTaskAsync("Expectation from DelayedValue", async () => await DelayedValue(expectedValue));
Assert.Equal(expectedValue, assertedReturnValue);
Logger.LogInformation("Experimental solution");
ExpectTask("Expectation from DelayedValue with out await", async () => await DelayedValue(expectedValue), out var assertedOutValue);
Assert.Equal(assertedOutValue, assertedReturnValue);
ExpectGroup("Expect group of conditions", () =>
{
Expect("Expectation from group 1", () => Assert.True(true));
Expect("Expectation from group 2", () => Assert.True(true));
});
#endregion
}
public static async Task DelayedAssert()
{
// Wait for 1000 ms using Task.Delay
await Task.Delay(1000);
Assert.True(true);
}
public static async Task<int> DelayedValue(int returnValue)
{
// Wait for 1000 ms using Task.Delay
await Task.Delay(1000);
return returnValue;
}
}