File tree Expand file tree Collapse file tree
TensionDev.UUID.Serialization.SystemTextJson.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,59 @@ public void TestWrite(bool useNullOptions)
4040 }
4141
4242 [ Fact ]
43- public void TestRead ( )
43+ public void TestReadNotString ( )
44+ {
45+ // Arrange
46+ // Use a canonical all-zero UUID representation which is commonly accepted by UUID parsers.
47+ const string input = "00000000-0000-0000-0000-000000000000" ;
48+ string jsonText = "0" ;
49+ byte [ ] json = Encoding . UTF8 . GetBytes ( jsonText ) ;
50+ var reader = new Utf8JsonReader ( json ) ;
51+ reader . Read ( ) ;
52+
53+ // Act
54+ JsonException ex = null ;
55+ try
56+ {
57+ _converter . Read ( ref reader , typeof ( Uuid ) , new JsonSerializerOptions ( ) ) ;
58+ }
59+ catch ( JsonException caught )
60+ {
61+ ex = caught ;
62+ }
63+
64+ // Assert
65+ Assert . NotNull ( ex ) ;
66+ }
67+
68+ [ Fact ]
69+ public void TestReadEmptyString ( )
70+ {
71+ // Arrange
72+ // Use a canonical all-zero UUID representation which is commonly accepted by UUID parsers.
73+ const string input = "00000000-0000-0000-0000-000000000000" ;
74+ string jsonText = "\" \" " ;
75+ byte [ ] json = Encoding . UTF8 . GetBytes ( jsonText ) ;
76+ var reader = new Utf8JsonReader ( json ) ;
77+ reader . Read ( ) ;
78+
79+ // Act
80+ JsonException ex = null ;
81+ try
82+ {
83+ _converter . Read ( ref reader , typeof ( Uuid ) , new JsonSerializerOptions ( ) ) ;
84+ }
85+ catch ( JsonException caught )
86+ {
87+ ex = caught ;
88+ }
89+
90+ // Assert
91+ Assert . NotNull ( ex ) ;
92+ }
93+
94+ [ Fact ]
95+ public void TestReadString ( )
4496 {
4597 // Arrange
4698 // Use a canonical all-zero UUID representation which is commonly accepted by UUID parsers.
You can’t perform that action at this time.
0 commit comments