public async Task MultipleMessageReadTest() { SetupStream("+OK\r\n+Test\r\n:100\r\n*3\r\n:1\r\n:2\r\n:3\r\n$6\r\nfoobar\r\n-Error message\r\n"); IRedisType result = await ReadAsync <RedisString>(); Assert.Equal(new RedisString("OK"), result); result = await ReadAsync <RedisString>(); Assert.Equal(new RedisString("Test"), result); result = await ReadAsync <RedisInteger>(); Assert.Equal(new RedisInteger(100), result); result = await ReadAsync <RedisArray>(); Assert.Equal(new RedisArray(new RedisInteger(1), new RedisInteger(2), new RedisInteger(3)), result); result = await ReadAsync <RedisBulkString>(); Assert.Equal(RedisBulkString.FromString("foobar"), result); result = await ReadAsync <RedisErorr>(); Assert.Equal(new RedisErorr("Error message"), result); }
public void BulkStringsWithSameContentHaveSameHashCode() { var string1 = RedisBulkString.FromString("test"); var string2 = RedisBulkString.FromString("test"); Assert.Equal(string1.GetHashCode(), string2.GetHashCode()); }
public async Task ReadBulkStringArrayTest() { SetupStream("*2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n"); var result = await ReadAsync <RedisArray>(); Assert.Equal(new RedisArray(RedisBulkString.FromString("foo"), RedisBulkString.FromString("bar")), result); }
public async Task ReadBulkStringTest() { SetupStream("$6\r\nfoobar\r\n"); var result = await ReadAsync <RedisBulkString>(); Assert.Equal(RedisBulkString.FromString("foobar"), result); }
public async Task ReadEmptyBulkStringTest() { SetupStream("$0\r\n\r\n"); var result = await ReadAsync <RedisBulkString>(); Assert.Equal(RedisBulkString.FromString(""), result); }
public async Task ReadArrayWithNullElementTest() { SetupStream("*3\r\n$3\r\nfoo\r\n$-1\r\n$3\r\nbar\r\n"); var result = await ReadAsync <RedisArray>(); Assert.Equal(new RedisArray(RedisBulkString.FromString("foo"), RedisBulkString.Null, RedisBulkString.FromString("bar")), result); }
public void BulkStringsWithDifferentContentAreNotEqual() { var string1 = RedisBulkString.FromString("test1"); var string2 = RedisBulkString.FromString("test2"); Assert.False(string1.Equals(string2)); Assert.False(string2.Equals(string1)); Assert.True(string1 != string2); Assert.True(string2 != string1); }
public void BulkStringsWithSameContentAreEqual() { var string1 = RedisBulkString.FromString("test"); var string2 = RedisBulkString.FromString("test"); Assert.True(string1.Equals(string2)); Assert.True(string2.Equals(string1)); Assert.True(string1 == string2); Assert.True(string2 == string1); }
public WhenDisconnecting() { _clientFactory = new Mock <IClientFactory>(); _client = new Mock <IClient>(); _client.Setup(s => s.SendAsync(new RedisArray(RedisBulkString.FromString("PING", Encoding.ASCII)), It.IsAny <CancellationToken>())) .ReturnsAsync(new RedisString("PONG")); _client.Setup(s => s.SendAsync(new RedisArray(RedisBulkString.FromString("QUIT", Encoding.ASCII)), It.IsAny <CancellationToken>())) .ReturnsAsync(new RedisString("OK")); _clientFactory.SetReturnsDefault(Task.FromResult(_client.Object)); var connection = new BasicConnection(new IPEndPoint(IPAddress.Loopback, 6379), _clientFactory.Object); connection.OpenAsync(CancellationToken.None).Wait(); _client.ResetCalls(); connection.DisconnectAsync(CancellationToken.None).Wait(); }
public IRedisType Build() { return(new RedisArray(new[] { RedisBulkString.FromString(_command) }.Concat(_args).ToArray())); }
public CommandBuilder WithArg(string arg) { _args.Add(RedisBulkString.FromString(arg)); return(this); }
public void BulkStringsAreNotEqualToNull() { var s = RedisBulkString.FromString("test"); Assert.False(s.Equals(null)); }
public void BulkStringsAreEqualToItself() { var s = RedisBulkString.FromString("test"); Assert.True(s.Equals(s)); }
public void ToStringIsCorrect() { var s = RedisBulkString.FromString("test"); Assert.Equal("0x74657374", s.ToString()); }
public void NonEmptyBulkStringLegnthIsCorrect() { var s = RedisBulkString.FromString("test"); Assert.Equal(4, s.Length); }
public void ValueIsCorrect() { var s = RedisBulkString.FromString("test"); Assert.Equal(new byte[] { 0x74, 0x65, 0x73, 0x74 }, s.Value); }
public async Task WriteMixedArrayTest() { var result = await WriteAsync(new RedisArray(new RedisInteger(1), new RedisInteger(2), new RedisInteger(3), new RedisInteger(4), RedisBulkString.FromString("foobar"))); Assert.Equal("*5\r\n:1\r\n:2\r\n:3\r\n:4\r\n$6\r\nfoobar\r\n", result); }
public async Task WriteArrayWithNullElementTest() { var result = await WriteAsync(new RedisArray(RedisBulkString.FromString("foo"), RedisBulkString.Null, RedisBulkString.FromString("bar"))); Assert.Equal("*3\r\n$3\r\nfoo\r\n$-1\r\n$3\r\nbar\r\n", result); }
public async Task WriteBulkStringTest() { var result = await WriteAsync(RedisBulkString.FromString("foobar")); Assert.Equal("$6\r\nfoobar\r\n", result); }
public async Task ReadMixedArrayTest() { SetupStream("*5\r\n:1\r\n:2\r\n:3\r\n:4\r\n$6\r\nfoobar\r\n"); var result = await ReadAsync <RedisArray>(); Assert.Equal(new RedisArray(new RedisInteger(1), new RedisInteger(2), new RedisInteger(3), new RedisInteger(4), RedisBulkString.FromString("foobar")), result); }
public void ThenAQuitMessageIsSent() { _client.Verify(s => s.SendAsync(It.Is <IRedisType>(dt => dt.RedisType == RedisType.Array && (dt as RedisArray).Cast <RedisBulkString>().First() == RedisBulkString.FromString("QUIT", Encoding.ASCII)), CancellationToken.None)); }
public async Task WriteBulkStringArrayTest() { var result = await WriteAsync(new RedisArray(RedisBulkString.FromString("foo"), RedisBulkString.FromString("bar"))); Assert.Equal("*2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n", result); }