@@ -1152,4 +1152,38 @@ public async Task TestGetIssue198_Async()
1152
1152
Assert . Null ( result ) ;
1153
1153
Assert . Null ( result2 ) ;
1154
1154
}
1155
+
1156
+ [ Fact ]
1157
+ public void TestSetWithSerializationOption ( )
1158
+ {
1159
+ var commands = new JsonCommands ( redisFixture . Redis . GetDatabase ( ) ) ;
1160
+ var keys = CreateKeyNames ( 1 ) ;
1161
+ var key = keys [ 0 ] ;
1162
+ var jsonOptions = new JsonSerializerOptions { IncludeFields = true } ;
1163
+ var person = new Person { Name = "Developer" , Age = 23 , Birthday = DateTime . Today } ;
1164
+ commands . Set ( key , "$" , person , serializerOptions : jsonOptions ) ;
1165
+ Person ? result = commands . Get < Person > ( key , serializerOptions : jsonOptions ) ;
1166
+ Assert . NotNull ( result ) ;
1167
+ Assert . Equal ( person . Name , result ! . Name ) ;
1168
+ Assert . Equal ( person . Age , result ! . Age ) ;
1169
+ Assert . NotNull ( result ! . Birthday ) ;
1170
+ Assert . Equal ( person . Birthday , result ! . Birthday ) ;
1171
+ }
1172
+
1173
+ [ Fact ]
1174
+ public async Task TestSetAsyncWithSerializationOption ( )
1175
+ {
1176
+ var commands = new JsonCommands ( redisFixture . Redis . GetDatabase ( ) ) ;
1177
+ var keys = CreateKeyNames ( 1 ) ;
1178
+ var key = keys [ 0 ] ;
1179
+ var jsonOptions = new JsonSerializerOptions { IncludeFields = true } ;
1180
+ var person = new Person { Name = "Developer" , Age = 23 , Birthday = DateTime . Today } ;
1181
+ await commands . SetAsync ( key , "$" , person , serializerOptions : jsonOptions ) ;
1182
+ Person ? result = await commands . GetAsync < Person > ( key , serializerOptions : jsonOptions ) ;
1183
+ Assert . NotNull ( result ) ;
1184
+ Assert . Equal ( person . Name , result ! . Name ) ;
1185
+ Assert . Equal ( person . Age , result ! . Age ) ;
1186
+ Assert . NotNull ( result ! . Birthday ) ;
1187
+ Assert . Equal ( person . Birthday , result ! . Birthday ) ;
1188
+ }
1155
1189
}
0 commit comments