Beispiel #1
0
        public void GetUtcExpirationTimeRelativeToNow_WithAbsoluteExpirationTime()
        {
            CacheOptions options = new CacheOptions();

            options.AbsoluteExpirationTime = new DateTime(1970, 1, 3, 0, 0, 0, DateTimeKind.Utc);

            Assert.AreEqual(new DateTime(1970, 1, 3, 0, 0, 0, DateTimeKind.Utc), options.GetUtcExpirationTimeRelativeToNow());
        }
Beispiel #2
0
        public void GetUtcExpirationTimeRelativeToNow_WithSlidingExpirationTime()
        {
            CacheOptions options = new CacheOptions();

            options.SlidingExpirationTimeSpan = new TimeSpan(1, 2, 3);

            TimeSpan actualSpan = options.GetUtcExpirationTimeRelativeToNow() - DateTime.UtcNow;

            Assert.Between(actualSpan, new TimeSpan(1, 2, 1), new TimeSpan(1, 2, 5));
        }
Beispiel #3
0
        /// <inheritdoc />
        protected override void InternalSet(string key, object value, CacheOptions options)
        {
            DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow();

            client.Set(key, value, expirationTime);
        }
Beispiel #4
0
        public void GetUtcExpirationTimeRelativeToNow_NoExpirationTime()
        {
            CacheOptions options = new CacheOptions();

            Assert.AreEqual(DateTime.MaxValue, options.GetUtcExpirationTimeRelativeToNow());
        }
        public void GetUtcExpirationTimeRelativeToNow_WithSlidingExpirationTime()
        {
            CacheOptions options = new CacheOptions();
            options.SlidingExpirationTimeSpan = new TimeSpan(1, 2, 3);

            TimeSpan actualSpan = options.GetUtcExpirationTimeRelativeToNow() - DateTime.UtcNow;
            Assert.Between(actualSpan, new TimeSpan(1, 2, 1), new TimeSpan(1, 2, 5));
        }
        public void GetUtcExpirationTimeRelativeToNow_WithAbsoluteExpirationTime()
        {
            CacheOptions options = new CacheOptions();
            options.AbsoluteExpirationTime = new DateTime(1970, 1, 3, 0, 0, 0, DateTimeKind.Utc);

            Assert.AreEqual(new DateTime(1970, 1, 3, 0, 0, 0, DateTimeKind.Utc), options.GetUtcExpirationTimeRelativeToNow());
        }
 public void GetUtcExpirationTimeRelativeToNow_NoExpirationTime()
 {
     CacheOptions options = new CacheOptions();
     Assert.AreEqual(DateTime.MaxValue, options.GetUtcExpirationTimeRelativeToNow());
 }
        /// <inheritdoc />
        protected override void InternalSet(string key, object value, CacheOptions options)
        {
            DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow();

            client.Set(key, value, expirationTime);
        }