@@ -12,66 +12,18 @@ public class DefaultTempDataSerializerTest : TempDataSerializerTestBase
1212 protected override TempDataSerializer GetTempDataSerializer ( ) => new DefaultTempDataSerializer ( ) ;
1313
1414 [ Fact ]
15- public void RoundTripTest_StringThatLooksLikeCompliantDateTime ( )
15+ public void RoundTripTest_NonStandardDateTimeStringFormat_RoundTripsAsString ( )
1616 {
17- // This is an unintentional side-effect of trying to support a compat with JSON.NET.
18- // Any string that looks like a compliant DateTime object will be parsed as a DateTime.
19- // This test documents this behavior.
20- // Arrange
21- var key = "test-key" ;
22- var testProvider = GetTempDataSerializer ( ) ;
23- var value = new DateTime ( 2009 , 1 , 1 , 12 , 37 , 43 ) ;
24- var input = new Dictionary < string , object >
25- {
26- { key , value . ToString ( "r" ) }
27- } ;
28-
29- // Act
30- var bytes = testProvider . Serialize ( input ) ;
31- var values = testProvider . Deserialize ( bytes ) ;
17+ // DateTime that do not match the format that System.Text.Json uses for round-tripping
18+ // should round-trip as strings.
3219
33- // Assert
34- var roundTripValue = Assert . IsType < DateTime > ( values [ key ] ) ;
35- Assert . Equal ( value , roundTripValue ) ;
36- }
37-
38- [ Fact ]
39- public void RoundTripTest_StringThatIsNotCompliantDateTime ( )
40- {
41- // This is an unintentional side-effect of trying to support a compat with JSON.NET.
42- // Any string that looks like a compliant DateTime object will be parsed as a DateTime.
43- // This test documents this behavior.
4420 // Arrange
4521 var key = "test-key" ;
4622 var testProvider = GetTempDataSerializer ( ) ;
4723 var value = new DateTime ( 2009 , 1 , 1 , 12 , 37 , 43 ) ;
4824 var input = new Dictionary < string , object >
4925 {
50- { key , value . ToString ( ) }
51- } ;
52-
53- // Act
54- var bytes = testProvider . Serialize ( input ) ;
55- var values = testProvider . Deserialize ( bytes ) ;
56-
57- // Assert
58- var roundTripValue = Assert . IsType < string > ( values [ key ] ) ;
59- Assert . Equal ( value . ToString ( ) , roundTripValue ) ;
60- }
61-
62- [ Fact ]
63- public void RoundTripTest_StringThatIsNotCompliantGuid ( )
64- {
65- // This is an unintentional side-effect of trying to support a compat with JSON.NET.
66- // Any string that looks like a compliant DateTime object will be parsed as a DateTime.
67- // This test documents this behavior.
68- // Arrange
69- var key = "test-key" ;
70- var testProvider = GetTempDataSerializer ( ) ;
71- var value = Guid . NewGuid ( ) ;
72- var input = new Dictionary < string , object >
73- {
74- { key , value . ToString ( ) }
26+ { key , value . ToString ( "r" ) }
7527 } ;
7628
7729 // Act
@@ -80,7 +32,7 @@ public void RoundTripTest_StringThatIsNotCompliantGuid()
8032
8133 // Assert
8234 var roundTripValue = Assert . IsType < string > ( values [ key ] ) ;
83- Assert . Equal ( value . ToString ( ) , roundTripValue ) ;
35+ Assert . Equal ( value . ToString ( "r" ) , roundTripValue ) ;
8436 }
8537 }
8638}
0 commit comments