public async Task HashRemoveAsyncRangeByFileldListTest() { var test_key = "test_hash_remove_rang_by_fileld_list"; await _RedisService.HashRemoveAllAsync(test_key); var values = new List <HashEntry>(); for (int i = 0; i < 10; i++) { var hashEntry = new HashEntry(i, JsonManager.Serialize($"第{i}条测试数据")); values.Add(hashEntry); } _RedisService.HashSetRangeAsync(test_key, values).Wait(); var hashCount = _RedisService.HashCountAsync(test_key).Result; Assert.Equal(10, hashCount); var delFilelds = new List <RedisValue>() { 1, 2, 3 }; var delResult = _RedisService.HashRemoveAsync(test_key, delFilelds).Result; Assert.Equal(3, delResult); hashCount = _RedisService.HashCountAsync(test_key).Result; Assert.Equal(7, hashCount); var hashValue = _RedisService.HashGetAsync <string>(test_key, 1).Result; Assert.Null(hashValue); hashValue = _RedisService.HashGetAsync <string>(test_key, 2).Result; Assert.Null(hashValue); hashValue = _RedisService.HashGetAsync <string>(test_key, 3).Result; Assert.Null(hashValue); await _RedisService.HashRemoveAllAsync(test_key); }
public void Dserialize_Value_Error_Test() { Assert.Throws <Newtonsoft.Json.JsonSerializationException>(() => JsonManager.Deserialize <Test>("1111")); }
public void Serialize_Obj_NotNull_Test() { var result = JsonManager.Serialize <Test>(new Test()); Assert.NotEmpty(result); }
public void Serialize_Int_Test() { var result = JsonManager.Serialize(1); Assert.Equal("1", result); }
public void Serialize_Obj_Null_Test() { var result = JsonManager.Serialize <Test>(null); Assert.Empty(result); }