Пример #1
0
        public async Task TestScriptLoadAndRun_ListInList()
        {
            var dut = new AsyncRedisClient();

            await dut.Connect(LocalHostDefaultPort.AsConnectionSettings());

            var sha = await dut.LoadScript(ScriptWithListInListResult);

            Console.WriteLine(sha);

            var result = (await dut.EvalSha(sha, new string[0])).ToArray();

            Assert.AreEqual(2, result?.Length);

            var embeddedArray1 = result[0] as object[];
            var embeddedArray2 = result[1] as object[];

            Assert.AreEqual("10", embeddedArray1?[0]?.ToString());
            Assert.AreEqual("20", embeddedArray1?[1]?.ToString());
            Assert.AreEqual("30", embeddedArray1?[2]?.ToString());
            Assert.AreEqual("40", embeddedArray1?[3]?.ToString());

            Assert.AreEqual("10", embeddedArray2?[0]?.ToString());
            Assert.AreEqual("20", embeddedArray2?[1]?.ToString());
            Assert.AreEqual("30", embeddedArray2?[2]?.ToString());
            Assert.AreEqual("40", embeddedArray2?[3]?.ToString());
        }
Пример #2
0
        public async Task TestScriptLoadAndRun_SingleString()
        {
            var dut = new AsyncRedisClient();

            await dut.Connect(LocalHostDefaultPort.AsConnectionSettings());

            var sha = await dut.LoadScript(ScriptWithoutParameter);

            Assert.AreEqual(ShaLength, sha.Length);

            var res       = (await dut.EvalSha(sha, new string[0])).ToList();
            var resString = res[0];

            Assert.AreEqual("it works", resString);
        }
Пример #3
0
        public async Task TestScriptLoadAndRun_List()
        {
            var dut = new AsyncRedisClient();

            await dut.Connect(LocalHostDefaultPort.AsConnectionSettings());

            var sha = await dut.LoadScript(ScriptWithListResult);

            Console.WriteLine(sha);

            var res = await dut.EvalSha(sha, new string[0]);

            var resList = res as object[];

            Assert.AreEqual(2, resList?.Length);
            Assert.AreEqual("one", resList?[0] as string);
            Assert.AreEqual("two", resList?[1] as string);
        }