当前位置: 首页>>代码示例>>C#>>正文


C# FakeRedisSocket.GetMessage方法代码示例

本文整理汇总了C#中CSRedis.Internal.Fakes.FakeRedisSocket.GetMessage方法的典型用法代码示例。如果您正苦于以下问题:C# FakeRedisSocket.GetMessage方法的具体用法?C# FakeRedisSocket.GetMessage怎么用?C# FakeRedisSocket.GetMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSRedis.Internal.Fakes.FakeRedisSocket的用法示例。


在下文中一共展示了FakeRedisSocket.GetMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestExists

 public void TestExists()
 {
     using (var mock = new FakeRedisSocket(":1\r\n", ":0\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         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());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:11,代码来源:KeyTests.cs

示例2: TestExpire

 public void TestExpire()
 {
     using (var mock = new FakeRedisSocket(":1\r\n", ":0\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.IsTrue(redis.Expire("test1", TimeSpan.FromSeconds(10)));
         Assert.AreEqual("*3\r\n$6\r\nEXPIRE\r\n$5\r\ntest1\r\n$2\r\n10\r\n", mock.GetMessage());
         Assert.IsFalse(redis.Expire("test2", 20));
         Assert.AreEqual("*3\r\n$6\r\nEXPIRE\r\n$5\r\ntest2\r\n$2\r\n20\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:11,代码来源:KeyTests.cs

示例3: TestExpireAt

 public void TestExpireAt()
 {
     using (var mock = new FakeRedisSocket(":1\r\n", ":0\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         // 1402643208 = ISO 8601:2014-06-13T07:06:48Z
         Assert.IsTrue(redis.ExpireAt("test1", new DateTime(2014, 6, 13, 7, 6, 48)));
         Assert.AreEqual("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest1\r\n$10\r\n1402643208\r\n", mock.GetMessage());
         Assert.IsFalse(redis.ExpireAt("test2", 1402643208));
         Assert.AreEqual("*3\r\n$8\r\nEXPIREAT\r\n$5\r\ntest2\r\n$10\r\n1402643208\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:12,代码来源:KeyTests.cs

示例4: BitCountTest

        public void BitCountTest()
        {
            using (var mock = new FakeRedisSocket(":10\r\n", ":4\r\n"))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual(10, redis.BitCount("key"));
                Assert.AreEqual("*2\r\n$8\r\nBITCOUNT\r\n$3\r\nkey\r\n", mock.GetMessage());

                Assert.AreEqual(4, redis.BitCount("key", 0, 1));
                Assert.AreEqual("*4\r\n$8\r\nBITCOUNT\r\n$3\r\nkey\r\n$1\r\n0\r\n$1\r\n1\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:12,代码来源:StringTests.cs

示例5: SetUTF8Test

        public void SetUTF8Test()
        {
            using (var mock = new FakeRedisSocket("+OK\r\n", "+OK\r\n"))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                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());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:12,代码来源:RegressionTests.cs

示例6: TestBRPop

        public void TestBRPop()
        {
            string reply = "*2\r\n$4\r\ntest\r\n$5\r\ntest1\r\n";
            using (var mock = new FakeRedisSocket(reply, reply))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual("test1", redis.BRPop(60, "test"));
                Assert.AreEqual("*3\r\n$5\r\nBRPOP\r\n$4\r\ntest\r\n$2\r\n60\r\n", mock.GetMessage());

                Assert.AreEqual("test1", redis.BRPop(TimeSpan.FromMinutes(1), "test"));
                Assert.AreEqual("*3\r\n$5\r\nBRPOP\r\n$4\r\ntest\r\n$2\r\n60\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:13,代码来源:ListTests.cs

示例7: TestBLPopWithKey

        public void TestBLPopWithKey()
        {
            string reply = "*2\r\n$4\r\ntest\r\n$5\r\ntest1\r\n";
            using (var mock = new FakeRedisSocket(reply, reply))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                var response1 = redis.BLPopWithKey(60, "test");
                Assert.AreEqual("test", response1.Item1);
                Assert.AreEqual("test1", response1.Item2);
                Assert.AreEqual("*3\r\n$5\r\nBLPOP\r\n$4\r\ntest\r\n$2\r\n60\r\n", mock.GetMessage());

                var response2 = redis.BLPopWithKey(TimeSpan.FromMinutes(1), "test");
                Assert.AreEqual("*3\r\n$5\r\nBLPOP\r\n$4\r\ntest\r\n$2\r\n60\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:15,代码来源:ListTests.cs

示例8: BitPosTest

        public void BitPosTest()
        {
            using (var mock = new FakeRedisSocket(":10\r\n", ":10\r\n", ":10\r\n"))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual(10, redis.BitPos("key", true));
                Assert.AreEqual("*3\r\n$6\r\nBITPOS\r\n$3\r\nkey\r\n$1\r\n1\r\n", mock.GetMessage());

                Assert.AreEqual(10, redis.BitPos("key", true, start: 0));
                Assert.AreEqual("*4\r\n$6\r\nBITPOS\r\n$3\r\nkey\r\n$1\r\n1\r\n$1\r\n0\r\n", mock.GetMessage());

                Assert.AreEqual(10, redis.BitPos("key", true, start: 0, end: 1));
                Assert.AreEqual("*5\r\n$6\r\nBITPOS\r\n$3\r\nkey\r\n$1\r\n1\r\n$1\r\n0\r\n$1\r\n1\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:15,代码来源:StringTests.cs

示例9: TestHDel

 public void TestHDel()
 {
     using (var mock = new FakeRedisSocket(":2\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(2, redis.HDel("test", "test1", "test2"));
         Assert.AreEqual("*4\r\n$4\r\nHDEL\r\n$4\r\ntest\r\n$5\r\ntest1\r\n$5\r\ntest2\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:HashTests.cs

示例10: DiscardTest

 public void DiscardTest()
 {
     using (var mock = new FakeRedisSocket("+OK\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("OK", redis.Discard());
         Assert.AreEqual("*1\r\n$7\r\nDISCARD\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:TransactionTests.cs

示例11: BitOpTest

        public void BitOpTest()
        {
            using (var mock = new FakeRedisSocket(":10\r\n", ":10\r\n", ":10\r\n", ":10\r\n"))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual(10, redis.BitOp(RedisBitOp.And, "dest", "key1", "key2"));
                Assert.AreEqual("*5\r\n$5\r\nBITOP\r\n$3\r\nAND\r\n$4\r\ndest\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n", mock.GetMessage());

                Assert.AreEqual(10, redis.BitOp(RedisBitOp.Or, "dest", "key1", "key2"));
                Assert.AreEqual("*5\r\n$5\r\nBITOP\r\n$2\r\nOR\r\n$4\r\ndest\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n", mock.GetMessage());

                Assert.AreEqual(10, redis.BitOp(RedisBitOp.XOr, "dest", "key1", "key2"));
                Assert.AreEqual("*5\r\n$5\r\nBITOP\r\n$3\r\nXOR\r\n$4\r\ndest\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n", mock.GetMessage());

                Assert.AreEqual(10, redis.BitOp(RedisBitOp.Not, "dest", "key1", "key2"));
                Assert.AreEqual("*5\r\n$5\r\nBITOP\r\n$3\r\nNOT\r\n$4\r\ndest\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n", mock.GetMessage());
            }
        }
开发者ID:DTBruce,项目名称:csredis,代码行数:18,代码来源:StringTests.cs

示例12: WatchTest

 public void WatchTest()
 {
     using (var mock = new FakeRedisSocket("+OK\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("OK", redis.Watch());
         Assert.AreEqual("*1\r\n$5\r\nWATCH\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:TransactionTests.cs

示例13: AppendTest

 public void AppendTest()
 {
     using (var mock = new FakeRedisSocket(":10\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(10, redis.Append("key", "x"));
         Assert.AreEqual("*3\r\n$6\r\nAPPEND\r\n$3\r\nkey\r\n$1\r\nx\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:StringTests.cs

示例14: TestSInterStore

 public void TestSInterStore()
 {
     using (var mock = new FakeRedisSocket(":3\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(3, redis.SInterStore("destination", "key1", "key2"));
         Assert.AreEqual("*4\r\n$11\r\nSINTERSTORE\r\n$11\r\ndestination\r\n$4\r\nkey1\r\n$4\r\nkey2\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:SetTests.cs

示例15: TestSAdd

 public void TestSAdd()
 {
     using (var mock = new FakeRedisSocket(":3\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(3, redis.SAdd("test", "test1"));
         Assert.AreEqual("*3\r\n$4\r\nSADD\r\n$4\r\ntest\r\n$5\r\ntest1\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:SetTests.cs


注:本文中的CSRedis.Internal.Fakes.FakeRedisSocket.GetMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。