@@ -620,4 +620,86 @@ public void TestBRPopMultipleLists()
620620 Assert . Equal ( "list-one" , result ! . Item1 ) ;
621621 Assert . Equal ( "b" , result . Item2 . ToString ( ) ) ;
622622 }
623+
624+ [ SkipIfRedis ( Is . OSSCluster , Comparison . LessThan , "6.2.0" ) ]
625+ public void TestBLMove ( )
626+ {
627+ var redis = ConnectionMultiplexer . Connect ( "localhost" ) ;
628+
629+ var db = redis . GetDatabase ( null ) ;
630+ db . Execute ( "FLUSHALL" ) ;
631+
632+ db . ListRightPush ( "list-one" , "a" ) ;
633+ db . ListRightPush ( "list-one" , "b" ) ;
634+
635+ db . ListRightPush ( "list-two" , "c" ) ;
636+ db . ListRightPush ( "list-two" , "d" ) ;
637+
638+ var result = db . BLMove ( "list-one" , "list-two" , ListSide . Right , ListSide . Left , 0 ) ;
639+ Assert . NotNull ( result ) ;
640+ Assert . Equal ( "b" , result ! ) ;
641+
642+ Assert . Equal ( 1 , db . ListLength ( "list-one" ) ) ;
643+ Assert . Equal ( "a" , db . ListGetByIndex ( "list-one" , 0 ) ) ;
644+ Assert . Equal ( 3 , db . ListLength ( "list-two" ) ) ;
645+ Assert . Equal ( "b" , db . ListGetByIndex ( "list-two" , 0 ) ) ;
646+ Assert . Equal ( "c" , db . ListGetByIndex ( "list-two" , 1 ) ) ;
647+ Assert . Equal ( "d" , db . ListGetByIndex ( "list-two" , 2 ) ) ;
648+
649+ result = db . BLMove ( "list-two" , "list-one" , ListSide . Left , ListSide . Right , 0 ) ;
650+ Assert . NotNull ( result ) ;
651+ Assert . Equal ( "b" , result ! ) ;
652+
653+ Assert . Equal ( 2 , db . ListLength ( "list-one" ) ) ;
654+ Assert . Equal ( "a" , db . ListGetByIndex ( "list-one" , 0 ) ) ;
655+ Assert . Equal ( "b" , db . ListGetByIndex ( "list-one" , 1 ) ) ;
656+ Assert . Equal ( 2 , db . ListLength ( "list-two" ) ) ;
657+ Assert . Equal ( "c" , db . ListGetByIndex ( "list-two" , 0 ) ) ;
658+ Assert . Equal ( "d" , db . ListGetByIndex ( "list-two" , 1 ) ) ;
659+
660+ result = db . BLMove ( "list-one" , "list-two" , ListSide . Left , ListSide . Left , 0 ) ;
661+ Assert . NotNull ( result ) ;
662+ Assert . Equal ( "a" , result ! ) ;
663+
664+ Assert . Equal ( 1 , db . ListLength ( "list-one" ) ) ;
665+ Assert . Equal ( "b" , db . ListGetByIndex ( "list-one" , 0 ) ) ;
666+ Assert . Equal ( 3 , db . ListLength ( "list-two" ) ) ;
667+ Assert . Equal ( "a" , db . ListGetByIndex ( "list-two" , 0 ) ) ;
668+ Assert . Equal ( "c" , db . ListGetByIndex ( "list-two" , 1 ) ) ;
669+ Assert . Equal ( "d" , db . ListGetByIndex ( "list-two" , 2 ) ) ;
670+
671+ result = db . BLMove ( "list-two" , "list-one" , ListSide . Right , ListSide . Right , 0 ) ;
672+ Assert . NotNull ( result ) ;
673+ Assert . Equal ( "d" , result ! ) ;
674+
675+ Assert . Equal ( 2 , db . ListLength ( "list-one" ) ) ;
676+ Assert . Equal ( "b" , db . ListGetByIndex ( "list-one" , 0 ) ) ;
677+ Assert . Equal ( "d" , db . ListGetByIndex ( "list-one" , 1 ) ) ;
678+ Assert . Equal ( 2 , db . ListLength ( "list-two" ) ) ;
679+ Assert . Equal ( "a" , db . ListGetByIndex ( "list-two" , 0 ) ) ;
680+ Assert . Equal ( "c" , db . ListGetByIndex ( "list-two" , 1 ) ) ;
681+ }
682+
683+ [ SkipIfRedis ( Is . OSSCluster , Comparison . LessThan , "2.2.0" ) ]
684+ public void TestBRPopLPush ( )
685+ {
686+ var redis = ConnectionMultiplexer . Connect ( "localhost" ) ;
687+
688+ var db = redis . GetDatabase ( null ) ;
689+ db . Execute ( "FLUSHALL" ) ;
690+
691+ db . ListRightPush ( "list-one" , "a" ) ;
692+ db . ListRightPush ( "list-one" , "b" ) ;
693+
694+ db . ListRightPush ( "list-two" , "c" ) ;
695+ db . ListRightPush ( "list-two" , "d" ) ;
696+
697+ var result = db . BRPopLPush ( "list-one" , "list-two" , 0 ) ;
698+ Assert . NotNull ( result ) ;
699+ Assert . Equal ( "b" , result ! ) ;
700+
701+ Assert . Equal ( 1 , db . ListLength ( "list-one" ) ) ;
702+ Assert . Equal ( 3 , db . ListLength ( "list-two" ) ) ;
703+ Assert . Equal ( "b" , db . ListLeftPop ( "list-two" ) ) ;
704+ }
623705}
0 commit comments