|
7 | 7 |
|
8 | 8 | namespace TensionDev.UUID.Serialization.SystemTextJson.Tests |
9 | 9 | { |
10 | | - public class TestUuidSystemTextJsonConverter : IDisposable |
| 10 | + public class UuidSystemTextJsonConverterTests : IDisposable |
11 | 11 | { |
12 | 12 | private bool disposedValue; |
13 | 13 |
|
14 | 14 | private readonly UuidSystemTextJsonConverter _converter; |
15 | 15 |
|
16 | | - public TestUuidSystemTextJsonConverter() |
| 16 | + public UuidSystemTextJsonConverterTests() |
17 | 17 | { |
18 | 18 | _converter = new UuidSystemTextJsonConverter(); |
19 | 19 | } |
20 | 20 |
|
21 | 21 | [Theory] |
22 | | - [InlineData(true)] |
23 | | - [InlineData(false)] |
24 | | - public void TestWrite(bool useNullOptions) |
| 22 | + [InlineData(true, "00000000-0000-0000-0000-000000000000")] |
| 23 | + [InlineData(true, "ffffffff-ffff-ffff-ffff-ffffffffffff")] |
| 24 | + [InlineData(true, "164a714c-0c79-11ec-82a8-0242ac130003")] |
| 25 | + [InlineData(true, "550e8400-e29b-41d4-a716-446655440000")] |
| 26 | + [InlineData(true, "1bf6935b-49e6-54cf-a9c8-51fb21c41b46")] |
| 27 | + [InlineData(false, "00000000-0000-0000-0000-000000000000")] |
| 28 | + [InlineData(false, "ffffffff-ffff-ffff-ffff-ffffffffffff")] |
| 29 | + [InlineData(false, "164a714c-0c79-11ec-82a8-0242ac130003")] |
| 30 | + [InlineData(false, "550e8400-e29b-41d4-a716-446655440000")] |
| 31 | + [InlineData(false, "1bf6935b-49e6-54cf-a9c8-51fb21c41b46")] |
| 32 | + public void TestWrite(bool useNullOptions, string input) |
25 | 33 | { |
26 | 34 | // Arrange |
27 | 35 | using var ms = new MemoryStream(); |
28 | 36 | using var writer = new Utf8JsonWriter(ms); |
29 | | - Uuid value = new Uuid(); |
| 37 | + Uuid value = Uuid.Parse(input); |
30 | 38 | JsonSerializerOptions? options = useNullOptions ? null : new JsonSerializerOptions(); |
31 | 39 |
|
32 | 40 | // Act |
@@ -91,12 +99,15 @@ public void TestReadEmptyString() |
91 | 99 | Assert.NotNull(ex); |
92 | 100 | } |
93 | 101 |
|
94 | | - [Fact] |
95 | | - public void TestReadString() |
| 102 | + [Theory] |
| 103 | + [InlineData("00000000-0000-0000-0000-000000000000")] |
| 104 | + [InlineData("ffffffff-ffff-ffff-ffff-ffffffffffff")] |
| 105 | + [InlineData("164a714c-0c79-11ec-82a8-0242ac130003")] |
| 106 | + [InlineData("550e8400-e29b-41d4-a716-446655440000")] |
| 107 | + [InlineData("1bf6935b-49e6-54cf-a9c8-51fb21c41b46")] |
| 108 | + public void TestReadString(string input) |
96 | 109 | { |
97 | 110 | // Arrange |
98 | | - // Use a canonical all-zero UUID representation which is commonly accepted by UUID parsers. |
99 | | - const string input = "00000000-0000-0000-0000-000000000000"; |
100 | 111 | string jsonText = "\"" + input + "\""; |
101 | 112 | byte[] json = Encoding.UTF8.GetBytes(jsonText); |
102 | 113 | var reader = new Utf8JsonReader(json); |
@@ -126,7 +137,7 @@ protected virtual void Dispose(bool disposing) |
126 | 137 | } |
127 | 138 |
|
128 | 139 | // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources |
129 | | - // ~TestUuidSystemTextJsonConverter() |
| 140 | + // ~UuidSystemTextJsonConverterTests() |
130 | 141 | // { |
131 | 142 | // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method |
132 | 143 | // Dispose(disposing: false); |
|
0 commit comments