-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBasicChecks.cs
More file actions
64 lines (61 loc) · 3.02 KB
/
BasicChecks.cs
File metadata and controls
64 lines (61 loc) · 3.02 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 System.Collections.Generic;
using System.IO;
namespace CheckTestOutput
{
public static class BasicChecks
{
/// <summary> Verifies that the provided <paramref name="output" /> equals to the `outputDirectory/TestClass.TestMethod.txt` file. </summary>
/// <param name="checkName"> If not null, checkName will be appended to the calling <paramref name="memberName" />. Intended to be used when having multiple checks in one method. </param>
public static void CheckString(
this OutputChecker t,
string output,
string checkName = null,
string fileExtension = "txt",
[System.Runtime.CompilerServices.CallerMemberName] string memberName = null,
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = null,
bool allowAlternatives = false)
{
t.CheckOutputCore(
output,
checkName,
$"{Path.GetFileNameWithoutExtension(sourceFilePath)}.{memberName}",
fileExtension,
allowAlternatives
);
}
/// <summary> Verifies that the provided <paramref name="output" /> equals to the `outputDirectory/TestClass.TestMethod.bin` file. </summary>
/// <param name="checkName"> If not null, checkName will be appended to the calling <paramref name="memberName" />. Intended to be used when having multiple checks in one method. </param>
public static void CheckBinary(
this OutputChecker t,
byte[] output,
string checkName = null,
string fileExtension = "bin",
[System.Runtime.CompilerServices.CallerMemberName] string memberName = null,
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = null)
{
t.CheckOutputBinaryCore(
output,
checkName,
$"{Path.GetFileNameWithoutExtension(sourceFilePath)}.{memberName}",
fileExtension
);
}
/// <summary> Verifies that the provided <paramref name="output" /> equals to the `outputDirectory/TestClass.TestMethod.txt` file. File is compared line-by-line. </summary>
/// <param name="checkName"> If not null, checkName will be appended to the calling <paramref name="memberName" />. Intended to be used when having multiple checks in one method. </param>
public static void CheckLines(
this OutputChecker t,
IEnumerable<string> output,
string checkName = null,
string fileExtension = "txt",
[System.Runtime.CompilerServices.CallerMemberName] string memberName = null,
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = null)
{
t.CheckOutputCore(
string.Join("\n", output),
checkName,
$"{Path.GetFileNameWithoutExtension(sourceFilePath)}.{memberName}",
fileExtension
);
}
}
}