public void DistributedCacheEmulatorTests()
        {
            DependencyContext.Using(c =>
            {
                var dateTimeProvider = new FakeDateTimeProvider();
                var cacheEmulator = new DistributedCacheEmulator();
                var key = "test";
                var value = new object();
                var cacheTimeout = 30;
                dateTimeProvider.Now = new DateTime(2000, 1, 1, 0, 0, 0);

                A.CallTo(() => c.Resolver.TryResolve<IDateTimeProvider>())
                    .ReturnsLazily(() => dateTimeProvider);

                Assert.Null(cacheEmulator.Get<object>(key));

                cacheEmulator.Set(key, value, TimeSpan.FromSeconds(cacheTimeout));
                Assert.Equal(value, cacheEmulator.Get<object>(key));

                dateTimeProvider.Now = dateTimeProvider.Now.AddSeconds(60);
                Assert.Null(cacheEmulator.Get<object>(key));

                cacheEmulator.Set(key, value, TimeSpan.FromSeconds(cacheTimeout));
                Assert.Equal(value, cacheEmulator.Get<object>(key));

                cacheEmulator.Set(key, value);
                dateTimeProvider.Now = dateTimeProvider.Now.AddSeconds(60);
                Assert.Equal(value, cacheEmulator.Get<object>(key));

                cacheEmulator.Reset();
                Assert.Null(cacheEmulator.Get<object>(key));

                Assert.Equal(1, cacheEmulator.Increment(key));
                Assert.Equal(2, cacheEmulator.Increment(key));
                cacheEmulator.Reset();
                Assert.Equal(2, cacheEmulator.Increment(key, 2));
            });
        }
        public void DistributedCacheEmulator_Reset_ClearsCacheItems()
        {
            var cache = new DistributedCacheEmulator();

            cache.Set("SomeInt", 1);
            cache.Set("SomeStr", "str");
            cache.Set("WithExpiration", true, TimeSpan.FromHours(10));

            Assert.Equal(1, cache.Get <int?>("SomeInt"));
            Assert.Equal("str", cache.Get <string>("SomeStr"));
            Assert.True(cache.Get <bool?>("WithExpiration"));

            cache.Reset();

            Assert.Null(cache.Get <int?>("SomeInt"));
            Assert.Null(cache.Get <string>("SomeStr"));
            Assert.Null(cache.Get <bool?>("WithExpiration"));
        }
 public void RemoveAll()
 {
     cache.Reset();
 }