@@ -331,6 +331,44 @@ public void TestModulePrefixs()
331331 Assert . NotEqual ( bf1 . GetHashCode ( ) , bf2 . GetHashCode ( ) ) ;
332332 }
333333
334+ [ Fact ]
335+ public void TestCard ( )
336+ {
337+ IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
338+ db . Execute ( "FLUSHALL" ) ;
339+ var bf = db . BF ( ) ;
340+
341+ // return 0 if the key does not exist:
342+ Assert . Equal ( 0 , bf . Card ( "notExist" ) ) ;
343+
344+ // Store a filter:
345+ Assert . True ( bf . Add ( "bf1" , "item_foo" ) ) ;
346+ Assert . Equal ( 1 , bf . Card ( "bf1" ) ) ;
347+
348+ // Error when key is of a type other than Bloom filter:
349+ db . StringSet ( "setKey" , "value" ) ;
350+ Assert . Throws < RedisServerException > ( ( ) => bf . Card ( "setKey" ) ) ;
351+ }
352+
353+ [ Fact ]
354+ public async Task TestCardAsync ( )
355+ {
356+ IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
357+ db . Execute ( "FLUSHALL" ) ;
358+ var bf = db . BF ( ) ;
359+
360+ // return 0 if the key does not exist:
361+ Assert . Equal ( 0 , await bf . CardAsync ( "notExist" ) ) ;
362+
363+ // Store a filter:
364+ Assert . True ( await bf . AddAsync ( "bf1" , "item_foo" ) ) ;
365+ Assert . Equal ( 1 , await bf . CardAsync ( "bf1" ) ) ;
366+
367+ // Error when key is of a type other than Bloom filter:
368+ db . StringSet ( "setKey" , "value" ) ;
369+ await Assert . ThrowsAsync < RedisServerException > ( ( ) => bf . CardAsync ( "setKey" ) ) ;
370+ }
371+
334372 [ Fact ]
335373 public void TestModulePrefixs1 ( )
336374 {
0 commit comments