Exemple #1
0
        public void CombinedResponses()
        {
            var str = ":45\r\n+OK\r\n$0\r\n\r\n$5\r\nhello\r\n$-1\r\n*0\r\n*-1\r\n+OK\r\n";

            for (int i = 1; i < str.Length + 10; i++)
            {
                var source = new DummySocketReader(str, i);

                Assert.AreEqual(45, RESPObject.Read <RESPInteger>(source).Value);
                Assert.AreEqual("OK", RESPObject.Read <RESPSimpleString>(source).Value);
                Assert.AreEqual(String.Empty, RESPObject.Read <RESPBulkString>(source).Value);
                Assert.AreEqual("hello", RESPObject.Read <RESPBulkString>(source).Value);
                Assert.AreEqual(null, RESPObject.Read <RESPBulkString>(source).Value);
                Assert.AreEqual(0, RESPObject.Read <RESPArray>(source).Count);
                Assert.AreEqual(0, RESPObject.Read <RESPArray>(source).Count);
                Assert.AreEqual("OK", RESPObject.Read <RESPSimpleString>(source).Value);
            }
        }
        public void CanCancelTransaction()
        {
            var result = new RESPObject[]
            {
                new RESPSimpleString("OK"),
                new RESPSimpleString("QUEUED"),
                new RESPSimpleString("QUEUED"),
                new RESPBulkString(null)
            };
            var headers = new[] { "MULTI", "INCR", "INCR", "EXEC" };

            Transaction.Consolidate(result, headers);

            Assert.IsNotNull(result);
            Assert.AreEqual("OK", result[0].GetString());
            Assert.AreEqual("QUEUED", result[1].GetString());
            Assert.AreEqual("QUEUED", result[2].GetString());
            Assert.AreEqual("EXECWATCHFAILED", result[3].Cast <RESPError>().Prefix);
        }
        public void CanConsolidateTransaction()
        {
            var result = new RESPObject[]
            {
                new RESPSimpleString("OK"),
                new RESPSimpleString("QUEUED"),
                new RESPSimpleString("QUEUED"),
                new RESPArray(new RESPSimpleString("OK"), new RESPSimpleString("OK"))
            };

            var headers = new [] { "MULTI", "INCR", "INCR", "EXEC" };

            Transaction.Consolidate(result, headers);

            Assert.IsNotNull(result);
            Assert.AreEqual("OK", result[0].GetString(), true);
            Assert.AreEqual("OK", result[1].GetString(), true);
            Assert.AreEqual("OK", result[2].GetString(), true);
            Assert.AreEqual("OK", result[3].GetString(), true);
        }