Пример #1
0
        public void TestFiveSecondTimeoutStruct()
        {
            var key = "time2";

            var now = DateTime.Now;

            _cache.Add(key, CacheExtensions.Wrap(now, DateTime.UtcNow.Add(new TimeSpan(0, 0, 5))));

            Thread.Sleep(new TimeSpan(0, 0, 2));

            var cached = CacheExtensions.Unwrap(_cache.Get <DateTime>(key));

            Assert.Equal(now, cached);

            Thread.Sleep(new TimeSpan(0, 0, 5));

            Assert.Null(_cache.Get <string>(key));
        }