public void TryGet_ChecksLocalCacheThenDistributedCache()
        {
            var localCache       = new MockLocalCache <int, int>();
            var distributedCache = new MockDistributedCache <int, int>();

            var twoTierCache = new TwoTierCache <int, int>(localCache, distributedCache, EqualityComparer <int> .Default);

            for (var i = 1; i <= 100; i++)
            {
                twoTierCache.TryGet(i).Result.Success.Should().BeFalse();
                localCache.TryGetExecutionCount.Should().Be(i);
                distributedCache.TryGetExecutionCount.Should().Be(i);
            }

            for (var i = 1; i <= 100; i++)
            {
                twoTierCache.Set(i, i, TimeSpan.FromSeconds(1)).AsTask().Wait();
                localCache.SetExecutionCount.Should().Be(i);
                distributedCache.SetExecutionCount.Should().Be(i);
            }

            for (var i = 1; i <= 100; i++)
            {
                var(success, value, _) = twoTierCache.TryGet(i).Result;
                success.Should().BeTrue();
                value.Should().Be(i);

                localCache.TryGetExecutionCount.Should().Be(100 + i);
                distributedCache.TryGetExecutionCount.Should().Be(100);
            }
        }
        public void TryGet_SetsValueInLocalCacheIfFoundInDistributedCache()
        {
            var localCache       = new MockLocalCache <int, int>();
            var distributedCache = new MockDistributedCache <int, int>();

            var twoTierCache = new TwoTierCache <int, int>(localCache, distributedCache, EqualityComparer <int> .Default);

            for (var i = 1; i <= 100; i++)
            {
                distributedCache.Set(i, i, TimeSpan.FromSeconds(100));
                distributedCache.SetExecutionCount.Should().Be(i);
            }

            for (var i = 1; i <= 100; i++)
            {
                var(success, value, _) = twoTierCache.TryGet(i).Result;
                success.Should().BeTrue();
                value.Should().Be(i);
                localCache.SetExecutionCount.Should().Be(i);
                localCache.TryGet(i, out var fromLocalCache).Should().BeTrue();
                fromLocalCache.Should().Be(i);
            }
        }