• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Redis.MockConnector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



MockConnector类属于Aoite.Redis命名空间,在下文中一共展示了MockConnector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ClientKillTest

        public void ClientKillTest()
        {
            var reply1 = "+OK\r\n";
            var reply2 = ":1\r\n";
            using(var mock = new MockConnector("localhost", 9999, reply1, reply2, reply2, reply2, reply2, reply2))
            using(var redis = new RedisClient(mock))
            {
                Assert.True(redis.ClientKill("1.1.1.1", 9999));
                Assert.Equal("*3\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$12\r\n1.1.1.1:9999\r\n", mock.GetMessage());

                Assert.Equal(1, redis.ClientKill(addr: "1.1.1.1:9999"));
                Assert.Equal("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$4\r\nADDR\r\n$12\r\n1.1.1.1:9999\r\n", mock.GetMessage());

                Assert.Equal(1, redis.ClientKill(id: "123"));
                Assert.Equal("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$2\r\nID\r\n$3\r\n123\r\n", mock.GetMessage());

                Assert.Equal(1, redis.ClientKill(type: "normal"));
                Assert.Equal("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$4\r\nTYPE\r\n$6\r\nnormal\r\n", mock.GetMessage());

                Assert.Equal(1, redis.ClientKill(skipMe: true));
                Assert.Equal("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$6\r\nSKIPME\r\n$3\r\nyes\r\n", mock.GetMessage());

                Assert.Equal(1, redis.ClientKill(skipMe: false));
                Assert.Equal("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$6\r\nSKIPME\r\n$2\r\nno\r\n", mock.GetMessage());
            }
        }
开发者ID:glorylee,项目名称:Aoite,代码行数:26,代码来源:RedisServerTests.cs


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: SelectTest

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


示例7: 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


示例8: 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


示例9: IncrTest

 public void IncrTest()
 {
     using(var mock = new MockConnector("localhost", 9999, ":5\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal(5, redis.IncrBy("key"));
         Assert.Equal("*2\r\n$4\r\nINCR\r\n$3\r\nkey\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisStringTests.cs


示例10: AppendTest

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


示例11: ClientListTest

 public void ClientListTest()
 {
     using(var mock = new MockConnector("localhost", 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.Equal("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.Equal("*2\r\n$6\r\nCLIENT\r\n$4\r\nLIST\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisServerTests.cs


示例12: GetSetTest

 public void GetSetTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "$5\r\nhello\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal("hello", (string)redis.GetSet("key", "new"));
         Assert.Equal("*3\r\n$6\r\nGETSET\r\n$3\r\nkey\r\n$3\r\nnew\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisStringTests.cs


示例13: AuthTest

 public void AuthTest()
 {
     using(var mock = new MockConnector("localhost", 9999, "+OK\r\n", "+OK\r\n"))
     using(var redis = new RedisClient(mock, "my password"))
     {
         redis._connector.Connect();
         Assert.Equal("*2\r\n$4\r\nAUTH\r\n$11\r\nmy password\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisConnectionTests.cs


示例14: DecrByTest

 public void DecrByTest()
 {
     using(var mock = new MockConnector("localhost", 9999, ":10\r\n"))
     using(var redis = new RedisClient(mock))
     {
         Assert.Equal(10, redis.DecrBy("key", 5));
         Assert.Equal("*3\r\n$6\r\nDECRBY\r\n$3\r\nkey\r\n$1\r\n5\r\n", mock.GetMessage());
     }
 }
开发者ID:glorylee,项目名称:Aoite,代码行数:9,代码来源:RedisStringTests.cs


示例15: QuitTest

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


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: TestSIsMember

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cassandra.ColumnParent类代码示例发布时间:2022-05-24
下一篇:
C# Ants.Location类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap