forked from VerifyTests/Verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GuidScrubberTests.cs
118 lines (105 loc) · 4.06 KB
/
GuidScrubberTests.cs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
public class GuidScrubberTests
{
#region NamedGuidGlobal
[ModuleInitializer]
public static void Init() => VerifierSettings.AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40c9"), "guidName");
#endregion
[Theory]
[InlineData("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "no match")]
[InlineData("aaaaaaaaaaaaaaaaaaaaaaaa", "no match short")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c", "simple")]
[InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c}", "curly")]
[InlineData("{173535ae-995b-4cc6-a74e-8cd4be57039c", "start-curly")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c}", "end-curly")]
[InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c-", "dash")]
[InlineData("-173535ae-995b-4cc6-a74e-8cd4be57039c", "start-dash")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c-", "end-dash")]
[InlineData("/173535ae-995b-4cc6-a74e-8cd4be57039c/", "fslash")]
[InlineData("/173535ae-995b-4cc6-a74e-8cd4be57039c", "start-fslash")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c/", "end-fslash")]
[InlineData("\\173535ae-995b-4cc6-a74e-8cd4be57039c\\}", "bslash")]
[InlineData("\\173535ae-995b-4cc6-a74e-8cd4be57039c", "start-bslash")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c\\", "end-bslash")]
[InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c]", "square")]
[InlineData("[173535ae-995b-4cc6-a74e-8cd4be57039c", "start-square")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c]", "end-square")]
[InlineData("a173535ae-995b-4cc6-a74e-8cd4be57039ca", "letters")]
[InlineData("a173535ae-995b-4cc6-a74e-8cd4be57039c", "start-letters")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039ca", "end-letters")]
[InlineData("1173535ae-995b-4cc6-a74e-8cd4be57039c1", "numbers")]
[InlineData("1173535ae-995b-4cc6-a74e-8cd4be57039c", "start-numbers")]
[InlineData("173535ae-995b-4cc6-a74e-8cd4be57039c1", "end-numbers")]
public async Task Run(string guid, string name)
{
var counter = Counter.Start();
try
{
var builder = new StringBuilder(guid);
GuidScrubber.ReplaceGuids(builder, counter);
await Verify(builder)
.UseTextForParameters(name);
}
finally
{
Counter.Stop();
}
}
[Theory]
[InlineData("c8eeaf99-d5c4-4341-8543-4597c3fd40c9", "named")]
[InlineData("c8eeaf99-d5c4-4341-8543-4597c3fd40d9", "instanceNamed")]
public Task NamedGuids(string guid, string name) =>
Verify(
new
{
value = new Guid(guid)
})
.AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40d9"), "instanceNamed")
.UseTextForParameters(name);
#region NamedGuidInstance
[Fact]
public Task NamedGuidInstance()
{
var settings = new VerifySettings();
var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
settings.AddNamedGuid(guid, "instanceNamed");
return Verify(
new
{
value = guid
},
settings);
}
#endregion
//top level should not scrub
[Fact]
public Task NamedGuidTopLevelInstance()
{
var settings = new VerifySettings();
var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
settings.AddNamedGuid(guid, "instanceNamed");
return Verify(guid, settings);
}
#region NamedGuidFluent
[Fact]
public Task NamedGuidFluent()
{
var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
return Verify(
new
{
value = guid
})
.AddNamedGuid(guid, "instanceNamed");
}
#endregion
[Fact]
public Task NamedGuidTopLevelFluent()
{
var guid = new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40d9");
return Verify(guid)
.AddNamedGuid(guid, "instanceNamed");
}
[Fact]
public Task NamedGuidTopLevelGlobal() =>
Verify(new Guid("c8eeaf99-d5c4-4341-8543-4597c3fd40c9"));
}