@@ -327,17 +327,15 @@ public async Task SimpleJsonInsertWhenAsync()
327
327
var host = Environment . GetEnvironmentVariable ( "STANDALONE_HOST_PORT" ) ?? "localhost" ;
328
328
var provider = new RedisConnectionProvider ( $ "redis://{ host } ") ;
329
329
var connection = provider . Connection ;
330
- var collection = new RedisCollection < Person > ( provider . Connection ) ;
330
+ var collection = new RedisCollection < BasicJsonObject > ( provider . Connection ) ;
331
331
332
- var obj = new Person { Name = "Steve" , Age = 33 } ;
332
+ var obj = new BasicJsonObject { Name = "Steve" } ;
333
333
var key = await collection . InsertAsync ( obj , WhenKey . NotExists ) ;
334
334
Assert . NotNull ( key ) ;
335
335
var reconstituted = await collection . FindByIdAsync ( key ) ;
336
336
Assert . NotNull ( reconstituted ) ;
337
337
Assert . Equal ( "Steve" , reconstituted . Name ) ;
338
- Assert . Equal ( 33 , reconstituted . Age ) ;
339
338
obj . Name = "Shachar" ;
340
- obj . Age = null ;
341
339
342
340
var res = await collection . InsertAsync ( obj , WhenKey . NotExists ) ; // this should fail
343
341
Assert . Null ( res ) ;
@@ -346,14 +344,17 @@ public async Task SimpleJsonInsertWhenAsync()
346
344
Assert . Equal ( key , res ) ;
347
345
reconstituted = await collection . FindByIdAsync ( key ) ;
348
346
Assert . NotNull ( reconstituted ) ;
349
- Assert . Null ( reconstituted . Age ) ;
350
347
Assert . Equal ( "Shachar" , reconstituted . Name ) ;
351
348
352
349
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 ) ;
354
353
var expiration = ( long ) await connection . ExecuteAsync ( "PTTL" , key ) ;
354
+ Assert . Equal ( key . Split ( ":" ) [ 1 ] , obj . Id ) ;
355
355
Assert . True ( expiration > 4000 ) ;
356
356
await Task . Delay ( 1000 ) ;
357
+ Assert . True ( connection . Execute ( "EXISTS" , key ) == 1 , $ "Expected: { key } to exist, it did not.") ;
357
358
res = await collection . InsertAsync ( obj , WhenKey . NotExists , TimeSpan . FromMilliseconds ( 5000 ) ) ;
358
359
Assert . Null ( res ) ;
359
360
expiration = ( long ) await connection . ExecuteAsync ( "PTTL" , key ) ;
@@ -380,17 +381,15 @@ public void SimpleJsonInsertWhen()
380
381
var host = Environment . GetEnvironmentVariable ( "STANDALONE_HOST_PORT" ) ?? "localhost" ;
381
382
var provider = new RedisConnectionProvider ( $ "redis://{ host } ") ;
382
383
var connection = provider . Connection ;
383
- var collection = new RedisCollection < Person > ( provider . Connection ) ;
384
+ var collection = new RedisCollection < BasicJsonObject > ( provider . Connection ) ;
384
385
385
- var obj = new Person { Name = "Steve" , Age = 33 } ;
386
+ var obj = new BasicJsonObject { Name = "Steve" } ;
386
387
var key = collection . Insert ( obj , WhenKey . NotExists ) ;
387
388
Assert . NotNull ( key ) ;
388
389
var reconstituted = collection . FindById ( key ) ;
389
390
Assert . NotNull ( reconstituted ) ;
390
391
Assert . Equal ( "Steve" , reconstituted . Name ) ;
391
- Assert . Equal ( 33 , reconstituted . Age ) ;
392
392
obj . Name = "Shachar" ;
393
- obj . Age = null ;
394
393
395
394
var res = collection . Insert ( obj , WhenKey . NotExists ) ; // this should fail
396
395
Assert . Null ( res ) ;
@@ -399,7 +398,6 @@ public void SimpleJsonInsertWhen()
399
398
Assert . Equal ( key , res ) ;
400
399
reconstituted = collection . FindById ( key ) ;
401
400
Assert . NotNull ( reconstituted ) ;
402
- Assert . Null ( reconstituted . Age ) ;
403
401
Assert . Equal ( "Shachar" , reconstituted . Name ) ;
404
402
405
403
connection . Unlink ( key ) ;
0 commit comments