@@ -33,10 +33,13 @@ public void CanConvertVersion()
3333 }
3434
3535 [ Theory ]
36- [ InlineData ( "1.0.0" ) ]
37- [ InlineData ( "2.0.0.0" ) ]
38- [ InlineData ( "3.0.0-alpha1" ) ]
39- public void SerializesSemanticVersionAsString ( string version )
36+ [ InlineData ( "1.0.0" , "1.0.0" ) ]
37+ [ InlineData ( "2.0.0.0" , "2.0.0.0" ) ]
38+ [ InlineData ( "3.0.0-alpha1" , "3.0.0-alpha1" ) ]
39+ [ InlineData ( "4.0.0-0test.zero" , "4.0.0-0test.zero" ) ]
40+ [ InlineData ( "4.0.0-0test.zero+tagParses" , "4.0.0-0test.zero" ) ]
41+ [ InlineData ( "4.0.0-test.more.parts+tagsHash" , "4.0.0-test.more.parts" ) ]
42+ public void SerializesSemanticVersionAsString ( string version , string expected )
4043 {
4144 // Arrange
4245 var json = new StringBuilder ( ) ;
@@ -48,7 +51,7 @@ public void SerializesSemanticVersionAsString(string version)
4851 converter . WriteJson ( writer , SemanticVersion . Parse ( version ) , new JsonSerializer ( ) ) ;
4952
5053 // Assert
51- Assert . Equal ( "\" " + version + "\" " , json . ToString ( ) ) ;
54+ Assert . Equal ( "\" " + expected + "\" " , json . ToString ( ) ) ;
5255 }
5356 }
5457
@@ -72,12 +75,16 @@ public void SerializesVersionAsString(string version)
7275 }
7376
7477 [ Theory ]
75- [ InlineData ( "1.0.0" , typeof ( SemanticVersion ) ) ]
76- [ InlineData ( "2.0.0.0" , typeof ( SemanticVersion ) ) ]
77- [ InlineData ( "3.0.0-alpha" , typeof ( SemanticVersion ) ) ]
78- [ InlineData ( "1.0.0" , typeof ( Version ) ) ]
79- [ InlineData ( "2.0.0.0" , typeof ( Version ) ) ]
80- public void Deserializes ( string version , Type type )
78+ [ InlineData ( "1.0.0" , typeof ( SemanticVersion ) , "1.0.0" ) ]
79+ [ InlineData ( "2.0.0.0" , typeof ( SemanticVersion ) , "2.0.0.0" ) ]
80+ [ InlineData ( "3.0.0-alpha" , typeof ( SemanticVersion ) , "3.0.0-alpha" ) ]
81+ [ InlineData ( "4.0.0-0test.zero" , typeof ( SemanticVersion ) , "4.0.0-0test.zero" ) ]
82+ [ InlineData ( "4.0.0-0test.zero+tagParses" , typeof ( SemanticVersion ) , "4.0.0-0test.zero" ) ]
83+ [ InlineData ( "4.0.0-test.more.parts+tagsHash" , typeof ( SemanticVersion ) , "4.0.0-test.more.parts" ) ]
84+ [ InlineData ( "4.0.0+tagsOnly" , typeof ( SemanticVersion ) , "4.0.0" ) ]
85+ [ InlineData ( "1.0.0" , typeof ( Version ) , "1.0.0" ) ]
86+ [ InlineData ( "2.0.0.0" , typeof ( Version ) , "2.0.0.0" ) ]
87+ public void Deserializes ( string version , Type type , string expected = null )
8188 {
8289 // Arrange
8390 using ( var reader = new JsonTextReader ( new StringReader ( "\" " + version + "\" " ) ) )
@@ -88,7 +95,7 @@ public void Deserializes(string version, Type type)
8895 var result = converter . ReadJson ( reader , type , null , new JsonSerializer ( ) ) ;
8996
9097 // Assert
91- Assert . Equal ( version , result . ToString ( ) ) ;
98+ Assert . Equal ( expected , result . ToString ( ) ) ;
9299 }
93100 }
94101 }
0 commit comments