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


C# MockConnector.GetMessage方法代码示例

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


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

示例1: ExecTests

        public void ExecTests()
        {
            var okReply = "+OK\r\n";
            using(var mock = new MockConnector("localhost", 9999, okReply, "+QUEUED\r\n", "+QUEUED\r\n", "*2\r\n" + okReply + okReply))
            using(var redis = new RedisClient(mock))
            {
                int x = 0;
                using(var tran = redis.BeginTransaction())
                {
                    Assert.Equal("*1\r\n$5\r\nMULTI\r\n", mock.GetMessage());
                    tran.On(tran.Set("key1", "value1"), r =>
                    {
                        Assert.True(r);
                        x += 1;
                    });
                    Assert.Equal("*3\r\n$3\r\nSET\r\n$4\r\nkey1\r\n$6\r\nvalue1\r\n", mock.GetMessage());
                    tran.On(tran.Set("key2", "value2"), r =>
                    {
                        Assert.True(r);
                        Assert.Equal(1, x);
                        x += 2;
                    });
                    Assert.Equal("*3\r\n$3\r\nSET\r\n$4\r\nkey2\r\n$6\r\nvalue2\r\n", mock.GetMessage());
                    tran.Commit();
                    Assert.Equal("*1\r\n$4\r\nEXEC\r\n", mock.GetMessage());
                }
                Assert.Equal(string.Empty, mock.GetMessage());
                Assert.Equal(3, x);
            }

            this.RealCall(redis =>
            {
                int x = 0;
                using(var tran = redis.BeginTransaction())
                {
                    tran.On(tran.Set("key1", "value1"), r =>
                    {
                        Assert.True(r);
                        x += 1;
                    });
                    tran.On(tran.Set("key2", "value2"), r =>
                    {
                        Assert.True(r);
                        Assert.Equal(1, x);
                        x += 2;
                    });
                    tran.Commit();
                }
                Assert.Equal(3, x);

                Assert.Equal("value1", (string)redis.Get("key1"));
                Assert.Equal("value2", (string)redis.Get("key2"));
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:54,代码来源:RedisTranTests.cs

示例2: MyTestMethod3

        public void MyTestMethod3()
        {
            using(var mock = new MockConnector("localhost", 9999, "+OK\r\n", "+OK\r\n"))
            using(var redis = new RedisClient(mock))
            {
                Assert.True(redis.Set("key", "value"));
                Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());

                Assert.True(redis.Set("key", "value"));
                Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());
            }
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:12,代码来源:RedisStreamTests.cs

示例3: TestBRPopLPush

        public void TestBRPopLPush()
        {
            string reply = "$5\r\ntest1\r\n";
            using (var mock = new MockConnector("localhost", 9999, reply, reply))
            using (var redis = new RedisClient(mock))
            {
                Assert.Equal("test1", (string)redis.BRPopLPush("test", "new", 60));
                Assert.Equal("*4\r\n$10\r\nBRPOPLPUSH\r\n$4\r\ntest\r\n$3\r\nnew\r\n$2\r\n60\r\n", mock.GetMessage());

                Assert.Equal("test1", (string)redis.BRPopLPush("test", "new", TimeSpan.FromMinutes(1)));
                Assert.Equal("*4\r\n$10\r\nBRPOPLPUSH\r\n$4\r\ntest\r\n$3\r\nnew\r\n$2\r\n60\r\n", mock.GetMessage());
            }
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:13,代码来源:RedisListTests.cs

示例4: TestBRPop

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

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

示例5: TestHGetAll

        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);
                }
            });
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:26,代码来源:RedisHashTests.cs

示例6: ScriptLoadTest

 public void ScriptLoadTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "$8\r\nchecksum\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal("checksum", redis.ScriptLoad("return 1"));
         Assert.Equal("*3\r\n$6\r\nSCRIPT\r\n$4\r\nLOAD\r\n$8\r\nreturn 1\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisScriptTests.cs

示例7: ScriptKillTest

 public void ScriptKillTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+OK\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.True(redis.ScriptKill());
         Assert.Equal("*2\r\n$6\r\nSCRIPT\r\n$4\r\nKILL\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisScriptTests.cs

示例8: TestZAdd_Array

 public void TestZAdd_Array()
 {
     using(var mock = new MockConnector("localhost", 9999, ":2\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal(2, redis.ZAdd("test", new RedisScoreItem(1.1, "test1"), new RedisScoreItem(2.2, "test2")));
         Assert.Equal("*6\r\n$4\r\nZADD\r\n$4\r\ntest\r\n$3\r\n1.1\r\n$5\r\ntest1\r\n$3\r\n2.2\r\n$5\r\ntest2\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisSortedSetTests.cs

示例9: TestZIncrby

 public void TestZIncrby()
 {
     using(var mock = new MockConnector("localhost", 9999, "$4\r\n3.14\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal(3.14, redis.ZIncrBy("test", 1.5, "test1"));
         Assert.Equal("*4\r\n$7\r\nZINCRBY\r\n$4\r\ntest\r\n$3\r\n1.5\r\n$5\r\ntest1\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisSortedSetTests.cs

示例10: TestZCard

 public void TestZCard()
 {
     using(var mock = new MockConnector("localhost", 9999, ":2\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal(2, redis.ZCard("test"));
         Assert.Equal("*2\r\n$5\r\nZCARD\r\n$4\r\ntest\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisSortedSetTests.cs

示例11: BgRewriteAofTest

 public void BgRewriteAofTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+OK\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.True(redis.BgRewriteAof());
         Assert.Equal("*1\r\n$12\r\nBGREWRITEAOF\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisServerTests.cs

示例12: TestSAdd

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

示例13: GetRangeTest

 public void GetRangeTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "$5\r\nhello\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal("hello", (string)redis.GetRange("key", 0, 10));
         Assert.Equal("*4\r\n$8\r\nGETRANGE\r\n$3\r\nkey\r\n$1\r\n0\r\n$2\r\n10\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisStringTests.cs

示例14: PingTest

 public void PingTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+PONG\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.True(redis.Ping());
         Assert.Equal("*1\r\n$4\r\nPING\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisConnectionTests.cs

示例15: ClientGetNameTest

 public void ClientGetNameTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "$6\r\nmyname\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal("myname", redis.ClientGetName());
         Assert.Equal("*2\r\n$6\r\nCLIENT\r\n$7\r\nGETNAME\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisServerTests.cs


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