public void PutItem_does_not_crash_if_cache_is_unavailable()
        {
            var cache = new RedisCache("unknown,abortConnect=false");
            RedisCacheException exception = null;
            cache.CachingFailed += (s, e) => exception = e;

            cache.PutItem("1", new object(), new[] { "ES1", "ES2" }, TimeSpan.MaxValue, DateTimeOffset.MaxValue);

            Assert.NotNull(exception);
            Assert.IsType(typeof(RedisConnectionException), exception.InnerException);
        }
        public void InvalidateItem_does_not_crash_if_cache_is_unavailable()
        {
            var cache = new RedisCache("unknown,abortConnect=false");
            RedisCacheException exception = null;
            cache.CachingFailed += (s, e) => exception = e;

            cache.InvalidateItem("1");

            Assert.NotNull(exception);
            Assert.IsType(typeof(RedisConnectionException), exception.InnerException);
        }
Exemple #3
0
        public void GetItem_does_not_crash_if_cache_is_unavailable()
        {
            var cache = new RedisCache("unknown,abortConnect=false");
            RedisCacheException exception = null;

            cache.CachingFailed += (s, e) => exception = e;

            var success = cache.GetItem("1", out var item);

            Assert.IsFalse(success);
            Assert.IsNull(item);
            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception.InnerException, typeof(RedisConnectionException));
            Assert.AreEqual("Redis | Caching failed for GetItem", exception.Message);
        }
        public void GetItem_does_not_crash_if_cache_is_unavailable()
        {
            var cache = new RedisCache("unknown,abortConnect=false");
            RedisCacheException exception = null;
            cache.CachingFailed += (s, e) => exception = e;

            object item;
            var success = cache.GetItem("1", out item);

            Assert.False(success);
            Assert.Null(item);
            Assert.NotNull(exception);
            Assert.IsType(typeof(RedisConnectionException), exception.InnerException);
            Assert.Equal(exception.Message, "Caching failed for GetItem");
        }