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

C# Fakes.FakeRedisSocket类代码示例

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

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



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

示例1: ClientKillTest

        public void ClientKillTest()
        {
            var reply1 = "+OK\r\n";
            var reply2 = ":1\r\n";
            using (var mock = new FakeRedisSocket(reply1, reply2, reply2, reply2, reply2, reply2))
            using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
            {
                Assert.AreEqual("OK", redis.ClientKill("1.1.1.1", 9999));
                Assert.AreEqual("*4\r\n$6\r\nCLIENT\r\n$4\r\nKILL\r\n$7\r\n1.1.1.1\r\n$4\r\n9999\r\n", mock.GetMessage());

                Assert.AreEqual(1, redis.ClientKill(addr: "1.1.1.1:9999"));
                Assert.AreEqual("*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.AreEqual(1, redis.ClientKill(id: "123"));
                Assert.AreEqual("*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.AreEqual(1, redis.ClientKill(type: "normal"));
                Assert.AreEqual("*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.AreEqual(1, redis.ClientKill(skipMe: true));
                Assert.AreEqual("*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.AreEqual(1, redis.ClientKill(skipMe: false));
                Assert.AreEqual("*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:DTBruce,项目名称:csredis,代码行数:26,代码来源:ServerTests.cs


示例2: BgSaveTest

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


示例3: BgRewriteAofTest

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


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


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


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


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


示例8: PfMergeTest

 public void PfMergeTest()
 {
     using (var mock = new FakeRedisSocket("+OK\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("OK", redis.PfMerge("destination", "source1", "source2"));
         Assert.AreEqual("*4\r\n$7\r\nPFMERGE\r\n$11\r\ndestination\r\n$7\r\nsource1\r\n$7\r\nsource2\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:HyperLogLogTests.cs


示例9: ClientGetNameTest

 public void ClientGetNameTest()
 {
     using (var mock = new FakeRedisSocket("$6\r\nmyname\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("myname", redis.ClientGetName());
         Assert.AreEqual("*2\r\n$6\r\nCLIENT\r\n$7\r\nGETNAME\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:ServerTests.cs


示例10: TestHGet

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


示例11: ScriptKillTest

 public void ScriptKillTest()
 {
     using (var mock = new FakeRedisSocket("+OK\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual("OK", redis.ScriptKill());
         Assert.AreEqual("*2\r\n$6\r\nSCRIPT\r\n$4\r\nKILL\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:ScriptingTests.cs


示例12: TestHExists

 public void TestHExists()
 {
     using (var mock = new FakeRedisSocket(":1\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.IsTrue(redis.HExists("test", "field"));
         Assert.AreEqual("*3\r\n$7\r\nHEXISTS\r\n$4\r\ntest\r\n$5\r\nfield\r\n", mock.GetMessage());
     }
 }
开发者ID:DTBruce,项目名称:csredis,代码行数:9,代码来源:HashTests.cs


示例13: PfCountTest

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


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


示例15: TestDump

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


示例16: TestZIncrby

 public void TestZIncrby()
 {
     using (var mock = new FakeRedisSocket("$4\r\n3.14\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(3.14, redis.ZIncrBy("test", 1.5, "test1"));
         Assert.AreEqual("*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:DTBruce,项目名称:csredis,代码行数:9,代码来源:SortedSetTests.cs


示例17: PfAddTest

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


示例18: TestZAdd_Tuple

 public void TestZAdd_Tuple()
 {
     using (var mock = new FakeRedisSocket(":2\r\n"))
     using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
     {
         Assert.AreEqual(2, redis.ZAdd("test", Tuple.Create(1.1, "test1"), Tuple.Create(2.2, "test2")));
         Assert.AreEqual("*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:DTBruce,项目名称:csredis,代码行数:9,代码来源:SortedSetTests.cs


示例19: TestZCard

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


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Models.SafeDataReader类代码示例发布时间:2022-05-24
下一篇:
C# Vfs.HleIoDrvFileArg类代码示例发布时间: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