Exemplo n.º 1
0
        public void RedisInsertManyTest()
        {
            RedisServer r = new RedisServer("localhost");

            r.Db = 3;
            r.KeyDelete("hash");
            r.HashSetMany("hash", new Dictionary <string, string> {
                { "1", "2" }, { "2", "3" }
            });
            var hash = r.HashGetAll("hash");

            Assert.AreEqual(hash.Length, 2);
            Assert.AreEqual("2", r.HashGet("hash", "1"));
            Assert.AreEqual("3", r.HashGet("hash", "2"));
            r.KeyDelete("hash");

            r.KeyDelete("set");
            r.SetAddManay("set", new List <string> {
                "1", "2", "3"
            });
            var set = r.SetMembers("set");

            Assert.AreEqual(set.Count, 3);
            Assert.AreEqual("1", set[0]);
            Assert.AreEqual("2", set[1]);
            Assert.AreEqual("3", set[2]);
            r.KeyDelete("set");


            r.KeyDelete("list");
            r.ListRightPushMany("list", new List <string> {
                "1", "2", "3", "4", "5"
            });
            Assert.AreEqual(5, r.ListLength("list"));
            Assert.AreEqual("1", r.ListLeftPop("list"));
            Assert.AreEqual("5", r.ListRightPop("list"));
            Assert.AreEqual("4", r.ListRightPop("list"));
            Assert.AreEqual("2", r.ListLeftPop("list"));
            r.KeyDelete("list");

            r.Dispose();
        }
Exemplo n.º 2
0
        public void RedisInsertManyTest()
        {
            RedisServer r = new RedisServer("localhost");

            r.Db = 3;
            r.KeyDelete("hash");
            r.HashSetMany("hash", new Dictionary<string, string> { { "1", "2" }, { "2", "3" } });
            var hash = r.HashGetAll("hash");
            Assert.AreEqual(hash.Length, 2);
            Assert.AreEqual("2", r.HashGet("hash", "1"));
            Assert.AreEqual("3", r.HashGet("hash", "2"));
            r.KeyDelete("hash");

            r.KeyDelete("set");
            r.SetAddManay("set", new List<string> { "1", "2", "3" });
            var set = r.SetMembers("set");
            Assert.AreEqual(set.Count, 3);
            Assert.AreEqual("1", set[0]);
            Assert.AreEqual("2", set[1]);
            Assert.AreEqual("3", set[2]);
            r.KeyDelete("set");

            r.KeyDelete("list");
            r.ListRightPushMany("list", new List<string> { "1", "2", "3", "4", "5" });
            Assert.AreEqual(5, r.ListLength("list"));
            Assert.AreEqual("1", r.ListLeftPop("list"));
            Assert.AreEqual("5", r.ListRightPop("list"));
            Assert.AreEqual("4", r.ListRightPop("list"));
            Assert.AreEqual("2", r.ListLeftPop("list"));
            r.KeyDelete("list");

            r.Dispose();
        }