@@ -58,13 +58,15 @@ public async void DeserializeFromUtf8StreamTest(string json, IGraphQLResponse ex
5858 var jsonBytes = Encoding . UTF8 . GetBytes ( json ) ;
5959 await using var ms = new MemoryStream ( jsonBytes ) ;
6060 var response = await DeserializeToUnknownType ( expectedResponse . Data ? . GetType ( ) ?? typeof ( object ) , ms ) ;
61+
6162 //var response = await Serializer.DeserializeFromUtf8StreamAsync<object>(ms, CancellationToken.None);
6263
6364 response . Data . Should ( ) . BeEquivalentTo ( expectedResponse . Data , options => options . WithAutoConversion ( ) ) ;
6465
6566 if ( expectedResponse . Errors is null )
6667 response . Errors . Should ( ) . BeNull ( ) ;
67- else {
68+ else
69+ {
6870 using ( new AssertionScope ( ) )
6971 {
7072 response . Errors . Should ( ) . NotBeNull ( ) ;
@@ -95,7 +97,7 @@ public async Task<IGraphQLResponse> DeserializeToUnknownType(Type dataType, Stre
9597 {
9698 MethodInfo mi = Serializer . GetType ( ) . GetMethod ( "DeserializeFromUtf8StreamAsync" , BindingFlags . Instance | BindingFlags . Public ) ;
9799 MethodInfo mi2 = mi . MakeGenericMethod ( dataType ) ;
98- var task = ( Task ) mi2 . Invoke ( Serializer , new object [ ] { stream , CancellationToken . None } ) ;
100+ var task = ( Task ) mi2 . Invoke ( Serializer , new object [ ] { stream , CancellationToken . None } ) ;
99101 await task ;
100102 var resultProperty = task . GetType ( ) . GetProperty ( "Result" , BindingFlags . Public | BindingFlags . Instance ) ;
101103 var result = resultProperty . GetValue ( task ) ;
@@ -105,9 +107,8 @@ public async Task<IGraphQLResponse> DeserializeToUnknownType(Type dataType, Stre
105107 [ Fact ]
106108 public async void CanDeserializeExtensions ( )
107109 {
108-
109110 var response = await ChatClient . SendQueryAsync ( new GraphQLRequest ( "query { extensionsTest }" ) ,
110- ( ) => new { extensionsTest = "" } )
111+ ( ) => new { extensionsTest = "" } )
111112 ;
112113
113114 response . Errors . Should ( ) . NotBeNull ( ) ;
@@ -134,8 +135,8 @@ query Droid($id: String!) {
134135 name
135136 }
136137 }" ,
137- new { id = id . ToString ( ) } ,
138- "Human" ) ;
138+ new { id = id . ToString ( ) } ,
139+ "Human" ) ;
139140
140141 var response = await StarWarsClient . SendQueryAsync ( graphQLRequest , ( ) => new { Human = new { Name = string . Empty } } ) ;
141142
@@ -152,7 +153,6 @@ public async void CanDoSerializationWithPredefinedTypes()
152153 Assert . Equal ( message , response . Data . AddMessage . Content ) ;
153154 }
154155
155-
156156 public class WithNullable
157157 {
158158 public int ? NullableInt { get ; set ; }
@@ -172,5 +172,25 @@ public void CanSerializeNullableInt()
172172
173173 action . Should ( ) . NotThrow ( ) ;
174174 }
175+
176+ public class WithNullableStruct
177+ {
178+ public DateTime ? NullableStruct { get ; set ; }
179+ }
180+
181+ [ Fact ]
182+ public void CanSerializeNullableStruct ( )
183+ {
184+ Action action = ( ) => Serializer . SerializeToString ( new GraphQLRequest
185+ {
186+ Query = "{}" ,
187+ Variables = new WithNullableStruct
188+ {
189+ NullableStruct = DateTime . Now
190+ }
191+ } ) ;
192+
193+ action . Should ( ) . NotThrow ( ) ;
194+ }
175195 }
176196}
0 commit comments