@@ -773,12 +773,46 @@ public async Task TestUpdateJson()
773
773
_mock . Setup ( x => x . Execute ( "FT.SEARCH" , It . IsAny < string [ ] > ( ) ) )
774
774
. Returns ( _mockReply ) ;
775
775
_mock . Setup ( x => x . ExecuteAsync ( "EVALSHA" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "42" ) ;
776
- _mock . Setup ( x => x . ExecuteAsync ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "42" ) ;
776
+ _mock . Setup ( x => x . ExecuteAsync ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" ) ;
777
+ var collection = new RedisCollection < Person > ( _mock . Object ) ;
778
+ var steve = collection . First ( x => x . Name == "Steve" ) ;
779
+ steve . Age = 33 ;
780
+ await collection . UpdateAsync ( steve ) ;
781
+ _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
782
+ Scripts . ShaCollection . Clear ( ) ;
783
+ }
784
+
785
+ [ Fact ]
786
+ public async Task TestUpdateJsonUnloadedScriptAsync ( )
787
+ {
788
+ _mock . Setup ( x => x . Execute ( "FT.SEARCH" , It . IsAny < string [ ] > ( ) ) )
789
+ . Returns ( _mockReply ) ;
790
+ _mock . Setup ( x => x . ExecuteAsync ( "EVALSHA" , It . IsAny < string [ ] > ( ) ) ) . Throws ( new RedisServerException ( "Failed on EVALSHA" ) ) ;
791
+ _mock . Setup ( x => x . ExecuteAsync ( "EVAL" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "42" ) ;
792
+ _mock . Setup ( x => x . ExecuteAsync ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" ) ;
777
793
var collection = new RedisCollection < Person > ( _mock . Object ) ;
778
794
var steve = collection . First ( x => x . Name == "Steve" ) ;
779
795
steve . Age = 33 ;
780
796
await collection . UpdateAsync ( steve ) ;
781
- _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "42" , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
797
+ _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
798
+ _mock . Verify ( x => x . ExecuteAsync ( "EVAL" , Scripts . JsonDiffResolution , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
799
+ Scripts . ShaCollection . Clear ( ) ;
800
+ }
801
+
802
+ [ Fact ]
803
+ public void TestUpdateJsonUnloadedScript ( )
804
+ {
805
+ _mock . Setup ( x => x . Execute ( "FT.SEARCH" , It . IsAny < string [ ] > ( ) ) )
806
+ . Returns ( _mockReply ) ;
807
+ _mock . Setup ( x => x . Execute ( "EVALSHA" , It . IsAny < string [ ] > ( ) ) ) . Throws ( new RedisServerException ( "Failed on EVALSHA" ) ) ;
808
+ _mock . Setup ( x => x . Execute ( "EVAL" , It . IsAny < string [ ] > ( ) ) ) . Returns ( "42" ) ;
809
+ _mock . Setup ( x => x . Execute ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . Returns ( "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" ) ;
810
+ var collection = new RedisCollection < Person > ( _mock . Object ) ;
811
+ var steve = collection . First ( x => x . Name == "Steve" ) ;
812
+ steve . Age = 33 ;
813
+ collection . Update ( steve ) ;
814
+ _mock . Verify ( x => x . Execute ( "EVALSHA" , "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb" , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
815
+ _mock . Verify ( x => x . Execute ( "EVAL" , Scripts . JsonDiffResolution , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Age" , "33" ) ) ;
782
816
Scripts . ShaCollection . Clear ( ) ;
783
817
}
784
818
@@ -803,18 +837,18 @@ public async Task TestUpdateJsonNestedObject()
803
837
_mock . Setup ( x => x . Execute ( "FT.SEARCH" , It . IsAny < string [ ] > ( ) ) )
804
838
. Returns ( _mockReply ) ;
805
839
_mock . Setup ( x => x . ExecuteAsync ( "EVALSHA" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "42" ) ;
806
- _mock . Setup ( x => x . ExecuteAsync ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "42 " ) ;
840
+ _mock . Setup ( x => x . ExecuteAsync ( "SCRIPT" , It . IsAny < string [ ] > ( ) ) ) . ReturnsAsync ( "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb " ) ;
807
841
var collection = new RedisCollection < Person > ( _mock . Object ) ;
808
842
var steve = collection . First ( x => x . Name == "Steve" ) ;
809
843
steve . Address = new Address { State = "Florida" } ;
810
844
await collection . UpdateAsync ( steve ) ;
811
845
var expected = $ "{{{Environment.NewLine} \" State\" : \" Florida\" { Environment . NewLine } }}";
812
- _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "42 " , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Address" , expected ) ) ;
846
+ _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb " , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Address" , expected ) ) ;
813
847
814
848
steve . Address . City = "Satellite Beach" ;
815
849
await collection . UpdateAsync ( steve ) ;
816
850
expected = "\" Satellite Beach\" " ;
817
- _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "42 " , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Address.City" , expected ) ) ;
851
+ _mock . Verify ( x => x . ExecuteAsync ( "EVALSHA" , "cbbf1c4fab5064f419e469cc51c563f8bf51e6fb " , "1" , "Redis.OM.Unit.Tests.RediSearchTests.Person:01FVN836BNQGYMT80V7RCVY73N" , "SET" , "$.Address.City" , expected ) ) ;
818
852
819
853
Scripts . ShaCollection . Clear ( ) ;
820
854
}
@@ -2572,7 +2606,7 @@ public void SearchWithEmptyAny()
2572
2606
"LIMIT" ,
2573
2607
"0" ,
2574
2608
"0" ) ) ;
2575
-
2609
+
2576
2610
Assert . True ( any ) ;
2577
2611
}
2578
2612
}
0 commit comments