Пример #1
0
        public void MyTestInitialize()
        {
            //初始化字符串
            RedisCommandTest test = new RedisCommandTest();

            test._command.StringSet("myStr", "hello world");
            test._command.StringSet("myStr", "hello world2", 1);
            test._command.StringSet("myCount", "0");
            test._command.StringSet("myCount2", "2");
            test._command.StringSet("myCount3", "3");
            test._command.StringSet("myCount2", "02", 1);
            test._command.StringSet("myCount3", "03", 1);
            test._command.StringSetBit("myBit", 0, true);
            //test._command.StringSetBit("myBit", 1, true);
            //test._command.StringSetBit("myBit", 2, true);
            //test._command.StringSetBit("myBit", 3, true);
            test._command.KeyDelete("StudentName", 1);
            test._command.KeyDelete("myCount1", 1);
            test._command.KeyDelete("myCount", 1);

            //初始化List
            test._command.KeyDelete("myList");
            List <string> list = new List <string>();

            for (int i = 0; i < 7; i++)
            {
                list.Add(i.ToString());
            }
            test._command.ListLeftPush("myList", list.ToArray());
            test._command.KeyDelete("mySet");
            test._command.SetAdd("mySet", list.ToArray());

            List <string> list2 = new List <string>();

            for (int i = 0; i < 3; i++)
            {
                list2.Add(i.ToString());
            }
            test._command.KeyDelete("mySet2");
            test._command.SetAdd("mySet2", list2.ToArray());
            test._command.KeyDelete("mySet3");
            test._command.KeyDelete("mySet4");
            list = new List <string>();
            for (int i = 0; i < 10; i++)
            {
                list.Add(i.ToString());
            }
            //初始化Set
            test._command.SetAdd("mySet4", list.ToArray());
            test._command.KeyDelete("myHash");
            test._command.HashSet("myHash", "name", "w");
            test._command.HashSet("myHash", "age", "1");
            test._command.HashSet("myHash", "year", "2017");
            test._command.HashSet("myHash", "month", "1");

            //初始化SortedSet
            _command.KeyDelete(new string[] { "mySortedSet", "mySortedSet2", "mySortedSet3" });
            _command.SortedSetAdd("mySortedSet",
                                  new string[] { "wuhan", "hangzhou", "beijing" }, new int[] { 1, 2, 3 });
            _command.SortedSetAdd("mySortedSet2",
                                  new string[] { "wuhan", "shanghai" }, new int[] { 1, 4 });

            //初始化Geo
            _command.KeyDelete("MyMap");
            _command.GeoAdd("MyMap", 114.31, 30.52, "WuHan", 2);
            _command.GeoAdd("MyMap", 121.48, 31.22, "ShangHai", 2);
            _command.GeoAdd("MyMap", 116.46, 39.92, "BeiJing", 2);
            _command.GeoAdd("MyMap", 113.31, 29.52, "YueYang", 2);
        }