public static void Main() { var client = new AsyncRedisClient(); var connectionSettings = new ConnectionSettings("127.0.0.1", 6379); FailIfException(async() => { Console.WriteLine($"Trying to connect to {connectionSettings.Address}:{connectionSettings.Port}..."); await client.Connect(connectionSettings); Pass(); }).GetAwaiter().GetResult(); FailIfException(async() => { Console.WriteLine("Trying simple write..."); await client.Set(Key, Value); Pass(); }).GetAwaiter().GetResult(); FailIfException(async() => { Console.WriteLine("Trying simple read..."); var result = await client.Get(Key); if (result == Value) { Pass(); } else { Fail("Read incorrect value from the server"); } }).GetAwaiter().GetResult(); FailIfException(async() => { Console.WriteLine("Trying DbSize..."); var result = await client.DbSize(); if (result == 1) { Pass(); } else { Fail("Read incorrect db size from the server"); } }).GetAwaiter().GetResult(); FailIfException(async() => { Console.WriteLine("Trying delete..."); await client.Del(Key); Pass(); }).GetAwaiter().GetResult(); }
public async Task Test_Set_Get() { var dut = new AsyncRedisClient(); await dut.Connect(LocalHostDefaultPort.AsConnectionSettings()); await dut.Set(Key, Value); var res = await dut.Get(Key); Assert.AreEqual(Value, res); }
public async Task TestWrongOperation_LRangeThrowsException() { Exception thrownException = null; var dut = new AsyncRedisClient(); await dut.Connect(LocalHostDefaultPort.AsConnectionSettings()); try { await dut.Set(ListKey, ListItems[0]); await dut.LRange(ListKey, 0, 1); } catch (Exception ex) { thrownException = ex; } Assert.IsNotNull(thrownException); Assert.IsInstanceOfType(thrownException, typeof(RedisException)); }