5
5
using Elasticsearch . Net ;
6
6
using FluentAssertions ;
7
7
using Nest ;
8
+ using Nest . JsonNetSerializer ;
8
9
9
10
namespace Tests . Reproduce
10
11
{
@@ -13,21 +14,24 @@ public class DateSerialization
13
14
[ U ]
14
15
public void ShouldRoundtripDateTimeAndDateTimeOffsetWithSameKindAndOffset ( )
15
16
{
16
- var dates = new Dates {
17
+ var dates = new Dates
18
+ {
17
19
DateTimeUtcKind = new DateTime ( 2016 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) ,
18
20
DateTimeOffset = new DateTimeOffset ( 1999 , 1 , 1 , 1 , 1 , 1 , 1 , TimeSpan . FromHours ( 5 ) ) ,
19
21
DateTimeOffsetUtc = new DateTimeOffset ( 1999 , 1 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero )
20
22
} ;
21
23
22
24
var client = new ElasticClient ( ) ;
23
- var serializedDates = client . SourceSerializer . SerializeToString ( dates , client . ConnectionSettings . MemoryStreamFactory , SerializationFormatting . None ) ;
25
+ var serializedDates =
26
+ client . SourceSerializer . SerializeToString ( dates , client . ConnectionSettings . MemoryStreamFactory , SerializationFormatting . None ) ;
24
27
25
28
serializedDates . Should ( )
26
29
. Contain ( "2016-01-01T01:01:01Z" )
27
30
. And . Contain ( "1999-01-01T01:01:01.0010000+05:00" )
28
31
. And . Contain ( "1999-01-01T01:01:01.0010000+00:00" ) ;
29
32
30
- using ( var stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( serializedDates ) ) ) {
33
+ using ( var stream = new MemoryStream ( Encoding . UTF8 . GetBytes ( serializedDates ) ) )
34
+ {
31
35
var deserializedDates = client . RequestResponseSerializer . Deserialize < Dates > ( stream ) ;
32
36
33
37
deserializedDates . DateTimeUtcKind . Should ( ) . Be ( dates . DateTimeUtcKind ) ;
@@ -42,6 +46,7 @@ public void ShouldRoundtripDateTimeAndDateTimeOffsetWithSameKindAndOffset()
42
46
deserializedDates . DateTimeOffsetUtc . Date . Kind . Should ( ) . Be ( dates . DateTimeOffsetUtc . Date . Kind ) ;
43
47
}
44
48
}
49
+
45
50
[ U ]
46
51
public void ShouldRoundtripDateTimeAndDateTimeOffsetWithSameKindAndOffsetNewtonsoft ( )
47
52
{
@@ -52,9 +57,10 @@ public void ShouldRoundtripDateTimeAndDateTimeOffsetWithSameKindAndOffsetNewtons
52
57
DateTimeOffsetUtc = new DateTimeOffset ( 1999 , 1 , 1 , 1 , 1 , 1 , 1 , TimeSpan . Zero )
53
58
} ;
54
59
55
- var sett = new ConnectionSettings ( new SingleNodeConnectionPool ( new Uri ( "http://localhost:9200" ) ) , Nest . JsonNetSerializer . JsonNetSerializer . Default ) ;
60
+ var sett = new ConnectionSettings ( new SingleNodeConnectionPool ( new Uri ( "http://localhost:9200" ) ) , JsonNetSerializer . Default ) ;
56
61
var client = new ElasticClient ( sett ) ;
57
- var serializedDates = client . SourceSerializer . SerializeToString ( dates , client . ConnectionSettings . MemoryStreamFactory , SerializationFormatting . None ) ;
62
+ var serializedDates =
63
+ client . SourceSerializer . SerializeToString ( dates , client . ConnectionSettings . MemoryStreamFactory , SerializationFormatting . None ) ;
58
64
59
65
serializedDates . Should ( )
60
66
. Contain ( "2016-01-01T01:01:01Z" )
0 commit comments