Skip to content

Commit

Permalink
better guid scrubbing
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Aug 16, 2022
1 parent 46a7615 commit d386631
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_bslash.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\Guid_1\}
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_curly.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{Guid_1}
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_dash.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Guid_1-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1\
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1-
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
173535ae-995b-4cc6-a74e-8cd4be57039ca
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
173535ae-995b-4cc6-a74e-8cd4be57039c1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1]
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_fslash.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Guid_1/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a173535ae-995b-4cc6-a74e-8cd4be57039ca
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1173535ae-995b-4cc6-a74e-8cd4be57039c1
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_simple.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Guid_1
1 change: 1 addition & 0 deletions src/Verify.Tests/GuidScrubberTests.Run_square.verified.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Guid_1]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\Guid_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{Guid_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Guid_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Guid_1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a173535ae-995b-4cc6-a74e-8cd4be57039c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1173535ae-995b-4cc6-a74e-8cd4be57039c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Guid_1
42 changes: 42 additions & 0 deletions src/Verify.Tests/GuidScrubberTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[UsesVerify]
public class GuidScrubberTests
{
[Theory]
[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)
{
Counter.Start();
try
{
var builder = new StringBuilder(guid);
GuidScrubber.ReplaceGuids(builder);
await Verify(builder)
.UseTextForParameters(name);
}
finally
{
Counter.Stop();
}
}
}
3 changes: 1 addition & 2 deletions src/Verify/Serialization/Scrubbers/GuidScrubber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ static bool IsInvalidEndingChar(char ch) =>

static bool IsInvalidChar(char ch) =>
char.IsLetter(ch) ||
char.IsNumber(ch) ||
ch is '-';
char.IsNumber(ch);

static bool IsInvalidStartingChar(char ch) =>
IsInvalidChar(ch) &&
Expand Down

0 comments on commit d386631

Please sign in to comment.