public async Task TryGetAsync_NoData()
        {
            _distributedCache.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(default(byte[]));

            DistributedCacheWrapperWithCompression distributedCacheWrapperWithCompression = new DistributedCacheWrapperWithCompression(_distributedCache.Object);

            (bool, object)result = await distributedCacheWrapperWithCompression.TryGetAsync <TestClass>(_key, CancellationToken.None, true);

            Assert.IsFalse(result.Item1);
            Assert.IsNull(result.Item2);
        }
        public async Task PutAsync()
        {
            DistributedCacheWrapperWithCompression distributedCacheWrapperWithCompression = new DistributedCacheWrapperWithCompression(_distributedCache.Object);

            await distributedCacheWrapperWithCompression.PutAsync(_key, _testClass, _ttl, CancellationToken.None, true);

            byte[] result = Utf8Json.JsonSerializer.Serialize(_testClass, StandardResolver.AllowPrivate);

            byte[] compressedBytes = CompressionUtils.Gzip(result);

            _distributedCache.Verify(x => x.SetAsync(It.Is <string>(y => y == _key), It.Is <byte[]>(y => y.SequenceEqual(compressedBytes)), It.Is <DistributedCacheEntryOptions>(y => y.AbsoluteExpirationRelativeToNow.Value == _ttl.Timespan), It.IsAny <CancellationToken>()));
        }
        public async Task TryGetAsync_Uncompressed()
        {
            byte[] serialisedTestClass = Utf8Json.JsonSerializer.Serialize(_testClass, StandardResolver.AllowPrivate);


            _distributedCache.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(serialisedTestClass);

            DistributedCacheWrapperWithCompression distributedCacheWrapperWithCompression = new DistributedCacheWrapperWithCompression(_distributedCache.Object);

            (bool, object)result = await distributedCacheWrapperWithCompression.TryGetAsync <TestClass>(_key, CancellationToken.None, true);

            Assert.IsTrue(result.Item1);
            Assert.AreEqual(_testClass.Property, ((TestClass)result.Item2).Property);
        }
        public void PutAsync_RetryTwiceOnRedisException()
        {
            RedisException redisException = (RedisException)FormatterServices.GetUninitializedObject(typeof(RedisException));

            _distributedCache.SetupSequence(x => x.SetAsync(It.Is <string>(y => y == _key), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>(), It.IsAny <CancellationToken>()))
            .Throws(redisException)
            .Throws(redisException)
            .Throws(redisException)
            .Throws(redisException);

            DistributedCacheWrapperWithCompression distributedCacheWrapperWithCompression = new DistributedCacheWrapperWithCompression(_distributedCache.Object);

            RedisException ex = Assert.ThrowsAsync <RedisException>(async() =>
            {
                await distributedCacheWrapperWithCompression.PutAsync(_key, _testClass, _ttl, CancellationToken.None, true);
            });

            _distributedCache.Verify(x => x.SetAsync(It.Is <string>(y => y == _key), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>(), It.IsAny <CancellationToken>()), Times.Exactly(3));
        }