コード例 #1
0
 public void TestExists()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":1\r\n", ":0\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.IsTrue(redis.Exists("test1"));
             Assert.AreEqual("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest1\r\n", mock.GetMessage());
             Assert.IsFalse(redis.Exists("test2"));
             Assert.AreEqual("*2\r\n$6\r\nEXISTS\r\n$5\r\ntest2\r\n", mock.GetMessage());
         }
 }
コード例 #2
0
 public void Persist()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":1\r\n", ":0\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.IsTrue(redis.Persist("test1"));
             Assert.AreEqual("*2\r\n$7\r\nPERSIST\r\n$5\r\ntest1\r\n", mock.GetMessage());
             Assert.IsFalse(redis.Persist("test2"));
             Assert.AreEqual("*2\r\n$7\r\nPERSIST\r\n$5\r\ntest2\r\n", mock.GetMessage());
         }
 }
コード例 #3
0
        public void AuthTest()
        {
            using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n", "+OK\r\n"))
                using (var redis = new RedisClient(mock))
                {
                    Assert.AreEqual("OK", redis.Auth("my password"));
                    Assert.AreEqual("*2\r\n$4\r\nAUTH\r\n$11\r\nmy password\r\n", mock.GetMessage());

                    Assert.AreEqual("OK", redis.AuthAsync("my password").Result);
                    Assert.AreEqual("*2\r\n$4\r\nAUTH\r\n$11\r\nmy password\r\n", mock.GetMessage());
                }
        }
コード例 #4
0
        public void SetUTF8Test()
        {
            using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n", "+OK\r\n"))
                using (var redis = new RedisClient(mock))
                {
                    Assert.AreEqual("OK", redis.Set("test", "é"));
                    Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());

                    Assert.AreEqual("OK", redis.SetAsync("test", "é").Result);
                    Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());
                }
        }
コード例 #5
0
ファイル: ServerTests.cs プロジェクト: henricj/csredis
        public void InfoTest()
        {
            var reply1 = "$1774\r\n# Server\r\nredis_version:2.8.12\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\nredis_build_id:15bba638a3b1acf9\r\nredis_mode:standalone\r\nos:Linux 2.6.32-220.17.1.el6.x86_64 x86_64\r\narch_bits:64\r\nmultiplexing_api:epoll\r\ngcc_version:4.4.6\r\nprocess_id:16533\r\nrun_id:76e33834f46f97e0acf1c2749245bc25758afe41\r\ntcp_port:6379\r\nuptime_in_seconds:183775\r\nuptime_in_days:2\r\nhz:10\r\nlru_clock:12351741\r\nconfig_file:/etc/redis.conf\r\n\r\n# Clients\r\nconnected_clients:2\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0\r\n\r\n# Memory\r\nused_memory:365208\r\nused_memory_human:356.65K\r\nused_memory_rss:7626752\r\nused_memory_peak:386120\r\nused_memory_peak_human:377.07K\r\nused_memory_lua:33792\r\nmem_fragmentation_ratio:20.88\r\nmem_allocator:jemalloc-3.6.0\r\n\r\n# Persistence\r\nloading:0\r\nrdb_changes_since_last_save:0\r\nrdb_bgsave_in_progress:0\r\nrdb_last_save_time:1404676894\r\nrdb_last_bgsave_status:ok\r\nrdb_last_bgsave_time_sec:-1\r\nrdb_current_bgsave_time_sec:-1\r\naof_enabled:0\r\naof_rewrite_in_progress:0\r\naof_rewrite_scheduled:0\r\naof_last_rewrite_time_sec:-1\r\naof_current_rewrite_time_sec:-1\r\naof_last_bgrewrite_status:ok\r\naof_last_write_status:ok\r\n\r\n# Stats\r\ntotal_connections_received:9\r\ntotal_commands_processed:23\r\ninstantaneous_ops_per_sec:0\r\nrejected_connections:0\r\nsync_full:0\r\nsync_partial_ok:0\r\nsync_partial_err:0\r\nexpired_keys:0\r\nevicted_keys:0\r\nkeyspace_hits:0\r\nkeyspace_misses:0\r\npubsub_channels:0\r\npubsub_patterns:0\r\nlatest_fork_usec:0\r\n\r\n# Replication\r\nrole:master\r\nconnected_slaves:0\r\nmaster_repl_offset:0\r\nrepl_backlog_active:0\r\nrepl_backlog_size:1048576\r\nrepl_backlog_first_byte_offset:0\r\nrepl_backlog_histlen:0\r\n\r\n# CPU\r\nused_cpu_sys:139.97\r\nused_cpu_user:43.93\r\nused_cpu_sys_children:0.00\r\nused_cpu_user_children:0.00\r\n\r\n# Keyspace\r\ndb0:keys=6,expires=0,avg_ttl=0\r\n";
            var reply2 = "$104\r\n# CPU\r\nused_cpu_sys:140.26\r\nused_cpu_user:43.95\r\nused_cpu_sys_children:0.00\r\nused_cpu_user_children:0.00\r\n";

            using (var mock = new MockConnector("MockHost", 9999, reply1, reply2))
                using (var redis = new RedisClient(mock))
                {
                    Assert.AreEqual("# Server\r\nredis_version:2.8.12\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\nredis_build_id:15bba638a3b1acf9\r\nredis_mode:standalone\r\nos:Linux 2.6.32-220.17.1.el6.x86_64 x86_64\r\narch_bits:64\r\nmultiplexing_api:epoll\r\ngcc_version:4.4.6\r\nprocess_id:16533\r\nrun_id:76e33834f46f97e0acf1c2749245bc25758afe41\r\ntcp_port:6379\r\nuptime_in_seconds:183775\r\nuptime_in_days:2\r\nhz:10\r\nlru_clock:12351741\r\nconfig_file:/etc/redis.conf\r\n\r\n# Clients\r\nconnected_clients:2\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0\r\n\r\n# Memory\r\nused_memory:365208\r\nused_memory_human:356.65K\r\nused_memory_rss:7626752\r\nused_memory_peak:386120\r\nused_memory_peak_human:377.07K\r\nused_memory_lua:33792\r\nmem_fragmentation_ratio:20.88\r\nmem_allocator:jemalloc-3.6.0\r\n\r\n# Persistence\r\nloading:0\r\nrdb_changes_since_last_save:0\r\nrdb_bgsave_in_progress:0\r\nrdb_last_save_time:1404676894\r\nrdb_last_bgsave_status:ok\r\nrdb_last_bgsave_time_sec:-1\r\nrdb_current_bgsave_time_sec:-1\r\naof_enabled:0\r\naof_rewrite_in_progress:0\r\naof_rewrite_scheduled:0\r\naof_last_rewrite_time_sec:-1\r\naof_current_rewrite_time_sec:-1\r\naof_last_bgrewrite_status:ok\r\naof_last_write_status:ok\r\n\r\n# Stats\r\ntotal_connections_received:9\r\ntotal_commands_processed:23\r\ninstantaneous_ops_per_sec:0\r\nrejected_connections:0\r\nsync_full:0\r\nsync_partial_ok:0\r\nsync_partial_err:0\r\nexpired_keys:0\r\nevicted_keys:0\r\nkeyspace_hits:0\r\nkeyspace_misses:0\r\npubsub_channels:0\r\npubsub_patterns:0\r\nlatest_fork_usec:0\r\n\r\n# Replication\r\nrole:master\r\nconnected_slaves:0\r\nmaster_repl_offset:0\r\nrepl_backlog_active:0\r\nrepl_backlog_size:1048576\r\nrepl_backlog_first_byte_offset:0\r\nrepl_backlog_histlen:0\r\n\r\n# CPU\r\nused_cpu_sys:139.97\r\nused_cpu_user:43.93\r\nused_cpu_sys_children:0.00\r\nused_cpu_user_children:0.00\r\n\r\n# Keyspace\r\ndb0:keys=6,expires=0,avg_ttl=0", redis.Info());
                    Assert.AreEqual("*1\r\n$4\r\nINFO\r\n", mock.GetMessage());

                    redis.Info("CPU");
                    Assert.AreEqual("*2\r\n$4\r\nINFO\r\n$3\r\nCPU\r\n", mock.GetMessage());
                }
        }
コード例 #6
0
ファイル: ServerTests.cs プロジェクト: henricj/csredis
        public void ShutdownTest()
        {
            using (var mock = new MockConnector("MockHost", 9999, "", "", ""))
                using (var redis = new RedisClient(mock))
                {
                    Assert.AreEqual(String.Empty, redis.Shutdown());
                    Assert.AreEqual("*1\r\n$8\r\nSHUTDOWN\r\n", mock.GetMessage());

                    Assert.AreEqual(String.Empty, redis.Shutdown(true));
                    Assert.AreEqual("*2\r\n$8\r\nSHUTDOWN\r\n$4\r\nSAVE\r\n", mock.GetMessage());

                    Assert.AreEqual(String.Empty, redis.Shutdown(false));
                    Assert.AreEqual("*2\r\n$8\r\nSHUTDOWN\r\n$6\r\nNOSAVE\r\n", mock.GetMessage());
                }
        }
コード例 #7
0
ファイル: ServerTests.cs プロジェクト: henricj/csredis
        public void SlowLogGetTest()
        {
            string reply = "*2\r\n*4\r\n:14\r\n:1309448221\r\n:15\r\n*1\r\n$4\r\nping\r\n*4\r\n:13\r\n:1309448128\r\n:30\r\n*3\r\n$7\r\nslowlog\r\n$3\r\nget\r\n$3\r\n100\r\n";

            using (var mock = new MockConnector("MockHost", 9999, reply, reply))
                using (var redis = new RedisClient(mock))
                {
                    var response = redis.SlowLogGet();
                    Assert.AreEqual(2, response.Length);
                    Assert.AreEqual(14, response[0].Id);
                    Assert.AreEqual(new DateTime(2011, 6, 30, 15, 37, 1, DateTimeKind.Utc), response[0].Date);
                    Assert.AreEqual(15, RedisDate.Micro.ToMicroseconds(response[0].Latency));
                    Assert.AreEqual(1, response[0].Arguments.Length);
                    Assert.AreEqual("ping", response[0].Arguments[0]);
                    Assert.AreEqual(13, response[1].Id);
                    Assert.AreEqual(new DateTime(2011, 6, 30, 15, 35, 28, DateTimeKind.Utc), response[1].Date);
                    Assert.AreEqual(30, RedisDate.Micro.ToMicroseconds(response[1].Latency));
                    Assert.AreEqual(3, response[1].Arguments.Length);
                    Assert.AreEqual("slowlog", response[1].Arguments[0]);
                    Assert.AreEqual("get", response[1].Arguments[1]);
                    Assert.AreEqual("100", response[1].Arguments[2]);
                    Assert.AreEqual("*2\r\n$7\r\nSLOWLOG\r\n$3\r\nGET\r\n", mock.GetMessage());

                    redis.SlowLogGet(5);
                    Assert.AreEqual("*3\r\n$7\r\nSLOWLOG\r\n$3\r\nGET\r\n$1\r\n5\r\n", mock.GetMessage());
                }
        }
コード例 #8
0
        public void TestScan()
        {
            var reply1 = "*2\r\n$1\r\n0\r\n*3\r\n$5\r\ntest1\r\n$5\r\ntest2\r\n$5\r\ntest3\r\n";
            var reply2 = "*2\r\n$1\r\n0\r\n*0\r\n";
            var reply3 = "*2\r\n$1\r\n0\r\n*0\r\n";
            var reply4 = "*2\r\n$1\r\n0\r\n*0\r\n";

            using (var mock = new MockConnector("MockHost", 9999, reply1, reply2, reply3, reply4))
                using (var redis = new RedisClient(mock))
                {
                    var resp = redis.Scan(0);
                    Assert.AreEqual(0, resp.Cursor);
                    Assert.AreEqual(3, resp.Items.Length);
                    for (int i = 0; i < resp.Items.Length; i++)
                    {
                        Assert.AreEqual("test" + (i + 1), resp.Items[i]);
                    }
                    Assert.AreEqual("*2\r\n$4\r\nSCAN\r\n$1\r\n0\r\n", mock.GetMessage());

                    redis.Scan(1, pattern: "pattern");
                    Assert.AreEqual("*4\r\n$4\r\nSCAN\r\n$1\r\n1\r\n$5\r\nMATCH\r\n$7\r\npattern\r\n", mock.GetMessage());

                    redis.Scan(2, count: 5);
                    Assert.AreEqual("*4\r\n$4\r\nSCAN\r\n$1\r\n2\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage());

                    redis.Scan(3, pattern: "pattern", count: 5);
                    Assert.AreEqual("*6\r\n$4\r\nSCAN\r\n$1\r\n3\r\n$5\r\nMATCH\r\n$7\r\npattern\r\n$5\r\nCOUNT\r\n$1\r\n5\r\n", mock.GetMessage());
                }
        }
コード例 #9
0
        public void TestSort()
        {
            using (var mock = new MockConnector("MockHost", 9999, "*2\r\n$2\r\nab\r\n$2\r\ncd\r\n", "*0\r\n", "*0\r\n", "*0\r\n", "*0\r\n", "*0\r\n", "*0\r\n", "*0\r\n"))
                using (var redis = new RedisClient(mock))
                {
                    var resp1 = redis.Sort("test1");
                    Assert.AreEqual(2, resp1.Length);
                    Assert.AreEqual("ab", resp1[0]);
                    Assert.AreEqual("cd", resp1[1]);
                    Assert.AreEqual("*2\r\n$4\r\nSORT\r\n$5\r\ntest1\r\n", mock.GetMessage());

                    var resp2 = redis.Sort("test2", offset: 0, count: 2);
                    Assert.AreEqual("*5\r\n$4\r\nSORT\r\n$5\r\ntest2\r\n$5\r\nLIMIT\r\n$1\r\n0\r\n$1\r\n2\r\n", mock.GetMessage());

                    var resp3 = redis.Sort("test3", by: "xyz");
                    Assert.AreEqual("*4\r\n$4\r\nSORT\r\n$5\r\ntest3\r\n$2\r\nBY\r\n$3\r\nxyz\r\n", mock.GetMessage());

                    var resp4 = redis.Sort("test4", dir: RedisSortDir.Asc);
                    Assert.AreEqual("*3\r\n$4\r\nSORT\r\n$5\r\ntest4\r\n$3\r\nASC\r\n", mock.GetMessage());

                    var resp5 = redis.Sort("test5", dir: RedisSortDir.Desc);
                    Assert.AreEqual("*3\r\n$4\r\nSORT\r\n$5\r\ntest5\r\n$4\r\nDESC\r\n", mock.GetMessage());

                    var resp6 = redis.Sort("test6", isAlpha: true);
                    Assert.AreEqual("*3\r\n$4\r\nSORT\r\n$5\r\ntest6\r\n$5\r\nALPHA\r\n", mock.GetMessage());

                    var resp7 = redis.Sort("test7", get: new[] { "get1", "get2" });
                    Assert.AreEqual("*6\r\n$4\r\nSORT\r\n$5\r\ntest7\r\n$3\r\nGET\r\n$4\r\nget1\r\n$3\r\nGET\r\n$4\r\nget2\r\n", mock.GetMessage());

                    var resp8 = redis.Sort("test8", offset: 0, count: 2, by: "xyz", dir: RedisSortDir.Asc, isAlpha: true, get: new[] { "a", "b" });
                    Assert.AreEqual("*13\r\n$4\r\nSORT\r\n$5\r\ntest8\r\n$2\r\nBY\r\n$3\r\nxyz\r\n$5\r\nLIMIT\r\n$1\r\n0\r\n$1\r\n2\r\n$3\r\nGET\r\n$1\r\na\r\n$3\r\nGET\r\n$1\r\nb\r\n$3\r\nASC\r\n$5\r\nALPHA\r\n", mock.GetMessage());
                }
        }
コード例 #10
0
        public void TestHGetAll()
        {
            using (var mock = new MockConnector("localhost", 9999, "*2\r\n$6\r\nfield1\r\n$5\r\ntest1\r\n"))
                using (var redis = new RedisClient(mock))
                {
                    var response = redis.HGetAll("test");
                    Assert.Equal(1, response.Length);
                    Assert.Equal("field1", response[0].Field);
                    Assert.Equal("test1", (string)response[0].Value);
                    Assert.Equal("*2\r\n$7\r\nHGETALL\r\n$4\r\ntest\r\n", mock.GetMessage());
                }

            this.RealCall(redis =>
            {
                redis.HSet("test", "field1", "value1");
                redis.HSet("test", "field2", "value2");

                var response = redis.HGetAll("test");
                Assert.Equal(2, response.Length);
                for (int i = 0; i < 2; i++)
                {
                    Assert.Equal("field" + (i + 1), response[i].Field);
                    Assert.Equal("value" + (i + 1), (string)response[i].Value);
                }
            });
        }
コード例 #11
0
 public void ScriptKillTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.ScriptKill());
             Assert.AreEqual("*2\r\n$6\r\nSCRIPT\r\n$4\r\nKILL\r\n", mock.GetMessage());
         }
 }
コード例 #12
0
 public void SelectTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.Select(2));
             Assert.AreEqual("*2\r\n$6\r\nSELECT\r\n$1\r\n2\r\n", mock.GetMessage());
         }
 }
コード例 #13
0
 public void PingTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+PONG\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("PONG", redis.Ping());
             Assert.AreEqual("*1\r\n$4\r\nPING\r\n", mock.GetMessage());
         }
 }
コード例 #14
0
 public void EchoTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$11\r\nhello world\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("hello world", redis.Echo("hello world"));
             Assert.AreEqual("*2\r\n$4\r\nECHO\r\n$11\r\nhello world\r\n", mock.GetMessage());
         }
 }
コード例 #15
0
 public void TestHLen()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":5\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(5, redis.HLen("test"));
             Assert.AreEqual("*2\r\n$4\r\nHLEN\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #16
0
ファイル: StringTests.cs プロジェクト: henricj/csredis
 public void DecrTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":10\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(10, redis.Decr("key"));
             Assert.AreEqual("*2\r\n$4\r\nDECR\r\n$3\r\nkey\r\n", mock.GetMessage());
         }
 }
コード例 #17
0
ファイル: TransactionTests.cs プロジェクト: henricj/csredis
 public void WatchTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.Watch());
             Assert.AreEqual("*1\r\n$5\r\nWATCH\r\n", mock.GetMessage());
         }
 }
コード例 #18
0
ファイル: ServerTests.cs プロジェクト: henricj/csredis
 public void ClientListTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$291\r\nid=3 addr=127.0.0.1:57656 fd=6 name= age=97 idle=81 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=client\nid=4 addr=127.0.0.1:57663 fd=7 name= age=5 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("id=3 addr=127.0.0.1:57656 fd=6 name= age=97 idle=81 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=client\nid=4 addr=127.0.0.1:57663 fd=7 name= age=5 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client", redis.ClientList());
             Assert.AreEqual("*2\r\n$6\r\nCLIENT\r\n$4\r\nLIST\r\n", mock.GetMessage());
         }
 }
コード例 #19
0
ファイル: SetTests.cs プロジェクト: henricj/csredis
 public void TestSPop()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$5\r\ntest1\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("test1", redis.SPop("test"));
             Assert.AreEqual("*2\r\n$4\r\nSPOP\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #20
0
 public void TestType()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.Type("test"));
             Assert.AreEqual("*2\r\n$4\r\nTYPE\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #21
0
 public void TestTtl()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":123\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(123, redis.Ttl("test"));
             Assert.AreEqual("*2\r\n$3\r\nTTL\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #22
0
 public void TestDump()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$4\r\ntest\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("test", redis.Encoding.GetString(redis.Dump("test")));
             Assert.AreEqual("*2\r\n$4\r\nDUMP\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #23
0
 public void TestRandomKey()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$7\r\nsomekey\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("somekey", redis.RandomKey());
             Assert.AreEqual("*1\r\n$9\r\nRANDOMKEY\r\n", mock.GetMessage());
         }
 }
コード例 #24
0
 public void PubSubNumPatTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":3\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(3, redis.PubSubNumPat());
             Assert.AreEqual("*2\r\n$6\r\nPUBSUB\r\n$6\r\nNUMPAT\r\n", mock.GetMessage());
         }
 }
コード例 #25
0
ファイル: TransactionTests.cs プロジェクト: henricj/csredis
 public void DiscardTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.Discard());
             Assert.AreEqual("*1\r\n$7\r\nDISCARD\r\n", mock.GetMessage());
         }
 }
コード例 #26
0
 public void TestZCard()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":2\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(2, redis.ZCard("test"));
             Assert.AreEqual("*2\r\n$5\r\nZCARD\r\n$4\r\ntest\r\n", mock.GetMessage());
         }
 }
コード例 #27
0
ファイル: StringTests.cs プロジェクト: henricj/csredis
 public void StrLenTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":10\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual(10, redis.StrLen("key"));
             Assert.AreEqual("*2\r\n$6\r\nSTRLEN\r\n$3\r\nkey\r\n", mock.GetMessage());
         }
 }
コード例 #28
0
ファイル: ServerTests.cs プロジェクト: henricj/csredis
 public void SlowLogResetTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "+OK\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("OK", redis.SlowLogReset());
             Assert.AreEqual("*2\r\n$7\r\nSLOWLOG\r\n$5\r\nRESET\r\n", mock.GetMessage());
         }
 }
コード例 #29
0
ファイル: StringTests.cs プロジェクト: henricj/csredis
 public void GetTest()
 {
     using (var mock = new MockConnector("MockHost", 9999, "$5\r\nhello\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.AreEqual("hello", redis.Get("key"));
             Assert.AreEqual("*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n", mock.GetMessage());
         }
 }
コード例 #30
0
 public void TestMove()
 {
     using (var mock = new MockConnector("MockHost", 9999, ":1\r\n"))
         using (var redis = new RedisClient(mock))
         {
             Assert.IsTrue(redis.Move("test", 5));
             Assert.AreEqual("*3\r\n$4\r\nMOVE\r\n$4\r\ntest\r\n$1\r\n5\r\n", mock.GetMessage());
         }
 }