public void HashGetAllAsyncBackWithHashEntryArrayTest()
        {
            var test_key = "test_hash_get_all";

            _RedisService.HashRemoveAllAsync(test_key).Wait();

            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 hashEntries = _RedisService.HashGetAllAsync(test_key).Result.ToList();

            Assert.Equal(10, hashEntries.Count());

            var firstValue = hashEntries.First();

            Assert.Equal("0", firstValue.Name);
            Assert.Equal("第0条测试数据", JsonManager.Deserialize <string>(firstValue.Value));

            _RedisService.HashRemoveAllAsync(test_key).Wait();
        }
Esempio n. 2
0
        public void Dserialize_Value_Empty_Test()
        {
            var result = JsonManager.Deserialize <Test>("");

            Assert.Null(result);

            result = JsonManager.Deserialize <Test>(string.Empty);

            Assert.Null(result);
        }
Esempio n. 3
0
 public void Dserialize_Value_Error_Test()
 {
     Assert.Throws <Newtonsoft.Json.JsonSerializationException>(() => JsonManager.Deserialize <Test>("1111"));
 }