Exemplo n.º 1
0
        public async Task ReadSimpleStringAsync()
        {
            var socket = Substitute.For <IAsyncSocket>();

            byte[][] responseData     = null;
            var      redisReader      = CreateRedisReader(100, socket);
            var      redisPiplineItem = new RedisPipelineItem(null, null, response => responseData = response);

            TestClient.SetupSocketResponse(socket, "+Boom!\r\n");

            await redisReader.ReadAsync(redisPiplineItem);

            Assert.Equal("Boom!", Encoding.UTF8.GetString(responseData[0]));
        }
Exemplo n.º 2
0
        public async Task ReadBulkStringInAwkwardChunks3Async()
        {
            var socket = Substitute.For <IAsyncSocket>();

            byte[][] responseData     = null;
            var      redisReader      = CreateRedisReader(100, socket);
            var      redisPiplineItem = new RedisPipelineItem(null, null, response => responseData = response);

            TestClient.SetupSocketResponse(socket, "*2\r\n", "$5\r\nBoom!\r\n$", "10\r\nShakalaka!", "\r\n");

            await redisReader.ReadAsync(redisPiplineItem);

            Assert.Equal("Boom!", Encoding.UTF8.GetString(responseData[0]));
        }
Exemplo n.º 3
0
        public async Task ReadBulkStringAsNullAsync()
        {
            var socket = Substitute.For <IAsyncSocket>();

            byte[][] responseData     = null;
            var      redisReader      = CreateRedisReader(100, socket);
            var      redisPiplineItem = new RedisPipelineItem(null, null, response => responseData = response);

            TestClient.SetupSocketResponse(socket, "$-1\r\n");

            await redisReader.ReadAsync(redisPiplineItem);

            Assert.Equal(null, responseData);
        }
Exemplo n.º 4
0
        public async Task ReadErrorAsync()
        {
            var socket = Substitute.For <IAsyncSocket>();

            Exception exception        = null;
            var       redisReader      = CreateRedisReader(100, socket);
            var       redisPiplineItem = new RedisPipelineItem(null, (error) => exception = error, null);

            TestClient.SetupSocketResponse(socket, "-ERR Oh no.\r\n");

            await redisReader.ReadAsync(redisPiplineItem);

            Assert.Equal("ERR Oh no.", exception.Message);
        }