public void GetIfCached_HandlesException()
        {
            // Arrange
            var key   = Guid.NewGuid().ToString();
            var cache = Substitute.For <ICache>();

            cache.GetIfCached(key, out Arg.Any <AClass>()).Throws(new Exception());
            var logger    = Substitute.For <ILogger <ExceptionHandlingCacheDecorator> >();
            var decorator = new ExceptionHandlingCacheDecorator(cache, logger);

            // Act
            var result = decorator.GetIfCached <AClass>(key, out var value);

            // Assert
            Assert.IsFalse(result);
            Assert.IsNull(value);
        }
        public void GetIfCached_ReturnsCachedValue()
        {
            // Arrange
            var key         = Guid.NewGuid().ToString();
            var cachedValue = new AClass();
            var cache       = Substitute.For <ICache>();

            cache.GetIfCached(key, out Arg.Any <AClass>()).Returns(x =>
            {
                x[1] = cachedValue;
                return(true);
            });
            var logger    = Substitute.For <ILogger <ExceptionHandlingCacheDecorator> >();
            var decorator = new ExceptionHandlingCacheDecorator(cache, logger);

            // Act
            var result = decorator.GetIfCached <AClass>(key, out var value);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(cachedValue, value);
        }