@@ -327,17 +327,15 @@ public async Task SimpleJsonInsertWhenAsync()
327327 var host = Environment . GetEnvironmentVariable ( "STANDALONE_HOST_PORT" ) ?? "localhost" ;
328328 var provider = new RedisConnectionProvider ( $ "redis://{ host } ") ;
329329 var connection = provider . Connection ;
330- var collection = new RedisCollection < Person > ( provider . Connection ) ;
330+ var collection = new RedisCollection < BasicJsonObject > ( provider . Connection ) ;
331331
332- var obj = new Person { Name = "Steve" , Age = 33 } ;
332+ var obj = new BasicJsonObject { Name = "Steve" } ;
333333 var key = await collection . InsertAsync ( obj , WhenKey . NotExists ) ;
334334 Assert . NotNull ( key ) ;
335335 var reconstituted = await collection . FindByIdAsync ( key ) ;
336336 Assert . NotNull ( reconstituted ) ;
337337 Assert . Equal ( "Steve" , reconstituted . Name ) ;
338- Assert . Equal ( 33 , reconstituted . Age ) ;
339338 obj . Name = "Shachar" ;
340- obj . Age = null ;
341339
342340 var res = await collection . InsertAsync ( obj , WhenKey . NotExists ) ; // this should fail
343341 Assert . Null ( res ) ;
@@ -346,14 +344,17 @@ public async Task SimpleJsonInsertWhenAsync()
346344 Assert . Equal ( key , res ) ;
347345 reconstituted = await collection . FindByIdAsync ( key ) ;
348346 Assert . NotNull ( reconstituted ) ;
349- Assert . Null ( reconstituted . Age ) ;
350347 Assert . Equal ( "Shachar" , reconstituted . Name ) ;
351348
352349 await connection . UnlinkAsync ( key ) ;
353- await collection . InsertAsync ( obj , WhenKey . NotExists , TimeSpan . FromMilliseconds ( 5000 ) ) ;
350+ var k2 = await collection . InsertAsync ( obj , WhenKey . NotExists , TimeSpan . FromMilliseconds ( 5000 ) ) ;
351+ Assert . NotNull ( k2 ) ;
352+ Assert . Equal ( key , k2 ) ;
354353 var expiration = ( long ) await connection . ExecuteAsync ( "PTTL" , key ) ;
354+ Assert . Equal ( key . Split ( ":" ) [ 1 ] , obj . Id ) ;
355355 Assert . True ( expiration > 4000 ) ;
356356 await Task . Delay ( 1000 ) ;
357+ Assert . True ( connection . Execute ( "EXISTS" , key ) == 1 , $ "Expected: { key } to exist, it did not.") ;
357358 res = await collection . InsertAsync ( obj , WhenKey . NotExists , TimeSpan . FromMilliseconds ( 5000 ) ) ;
358359 Assert . Null ( res ) ;
359360 expiration = ( long ) await connection . ExecuteAsync ( "PTTL" , key ) ;
@@ -380,17 +381,15 @@ public void SimpleJsonInsertWhen()
380381 var host = Environment . GetEnvironmentVariable ( "STANDALONE_HOST_PORT" ) ?? "localhost" ;
381382 var provider = new RedisConnectionProvider ( $ "redis://{ host } ") ;
382383 var connection = provider . Connection ;
383- var collection = new RedisCollection < Person > ( provider . Connection ) ;
384+ var collection = new RedisCollection < BasicJsonObject > ( provider . Connection ) ;
384385
385- var obj = new Person { Name = "Steve" , Age = 33 } ;
386+ var obj = new BasicJsonObject { Name = "Steve" } ;
386387 var key = collection . Insert ( obj , WhenKey . NotExists ) ;
387388 Assert . NotNull ( key ) ;
388389 var reconstituted = collection . FindById ( key ) ;
389390 Assert . NotNull ( reconstituted ) ;
390391 Assert . Equal ( "Steve" , reconstituted . Name ) ;
391- Assert . Equal ( 33 , reconstituted . Age ) ;
392392 obj . Name = "Shachar" ;
393- obj . Age = null ;
394393
395394 var res = collection . Insert ( obj , WhenKey . NotExists ) ; // this should fail
396395 Assert . Null ( res ) ;
@@ -399,7 +398,6 @@ public void SimpleJsonInsertWhen()
399398 Assert . Equal ( key , res ) ;
400399 reconstituted = collection . FindById ( key ) ;
401400 Assert . NotNull ( reconstituted ) ;
402- Assert . Null ( reconstituted . Age ) ;
403401 Assert . Equal ( "Shachar" , reconstituted . Name ) ;
404402
405403 connection . Unlink ( key ) ;
0 commit comments