public async Task Can_Clear_IList() { var storeMembers = Factory.CreateList(); await storeMembers.ForEachAsync(x => List.AddAsync(x)); Assert.That(await List.CountAsync(), Is.EqualTo(storeMembers.Count)); await List.ClearAsync(); Assert.That(await List.CountAsync(), Is.EqualTo(0)); }
public async Task Working_with_int_list_values() { const string intListKey = "intListKey"; var intValues = new List <int> { 2, 4, 6, 8 }; //STORING INTS INTO A LIST USING THE BASIC CLIENT await using (var redisClient = new RedisClient(TestConfig.SingleHost).ForAsyncOnly()) { IRedisListAsync strList = redisClient.Lists[intListKey]; //storing all int values in the redis list 'intListKey' as strings await intValues.ForEachAsync(async x => await strList.AddAsync(x.ToString())); //retrieve all values again as strings List <string> strListValues = await strList.ToListAsync(); //convert back to list of ints List <int> toIntValues = strListValues.ConvertAll(x => int.Parse(x)); Assert.That(toIntValues, Is.EqualTo(intValues)); //delete all items in the list await strList.ClearAsync(); } //STORING INTS INTO A LIST USING THE GENERIC CLIENT await using (var redisClient = new RedisClient(TestConfig.SingleHost).ForAsyncOnly()) { //Create a generic client that treats all values as ints: IRedisTypedClientAsync <int> intRedis = redisClient.As <int>(); IRedisListAsync <int> intList = intRedis.Lists[intListKey]; //storing all int values in the redis list 'intListKey' as ints await intValues.ForEachAsync(async x => await intList.AddAsync(x)); List <int> toIntListValues = await intList.ToListAsync(); Assert.That(toIntListValues, Is.EqualTo(intValues)); } }