-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (57 loc) · 2.36 KB
/
Copy pathProgram.cs
File metadata and controls
64 lines (57 loc) · 2.36 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
using SimpleFluentTester.Examples;
using SimpleFluentTester.TestSuite;
using SimpleFluentTester.TestSuite.Case;
// 1 Example.
// Setup test suite with default reporter (default output format).
// Then add few test cases, run them and print report.
TestSuite.Sequential
.WithDisplayName("First example")
.UseOperation(CustomMethods.Adder)
.Expect(2).WithInput(1, 1) // Number and type of input parameters should be the same as delegate's parameters, otherwise exception will be thrown.
.Expect(-3).WithInput(-1, -1)
.Run() // Could be used as .Run(1, 2) to run some specific test cases.
.Report(); // Prints the test execution result using default reporter.
// 2 Example.
// Setup test suite with custom reporter CustomReporterFactory.
// Then add few test cases, run them and print report.
TestSuite.Sequential
.WithDisplayName("Second example")
.UseOperation(CustomMethods.Adder)
.Expect(2).WithInput(1, 1)
.Expect(-3).WithInput(-1, -1)
.Run()
.Report((config, result) =>
{
config.ReportBuilder = new CustomTestSuiteReportBuilder(result);
config.ShouldPrintPredicate = testCase => testCase.Assert.Status == AssertStatus.NotPassed;
});
// 3 Example.
// This example shows that UseOperation could be skipped.
// Instead, TestSuiteDelegateAttribute could be used on target method.
TestSuite.Sequential
.WithDisplayName("Third example")
.Expect(2).WithInput(1, 1)
.Expect(-3).WithInput(-1, -1)
.Run()
.Report();
// 4 Example.
// This example demonstrates how custom types can be used with the TestSuite.
// To achieve this, define a comparer function using WithExpectedReturnType().
TestSuite.Sequential
.WithDisplayName("Fourth example")
.UseOperation(CustomMethods.CustomAdder)
.Expect(CustomValue.FromInt(2)).WithInput(CustomValue.FromInt(1), CustomValue.FromInt(1))
.Expect(CustomValue.FromInt(-3)).WithInput(CustomValue.FromInt(-1), CustomValue.FromInt(-1))
.WithComparer<CustomValue>((x, y) => x?.Value == y?.Value)
.Run()
.Report();
// 5 Example.
// Invalid inputs, test case number and expected value to demonstrate validation output.
TestSuite.Sequential
.WithDisplayName("Fifth example")
.UseOperation(CustomMethods.Adder)
.Expect(null).WithInput(1, 1)
.Expect(-3).WithInput(-1, -1, -1)
.Expect("-3").WithInput("test", -1)
.Run()
.Report();