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_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)); }
/// <inheritdoc /> protected override void InternalSet(string key, object value, CacheOptions options) { DateTime expirationTime = options.GetUtcExpirationTimeRelativeToNow(); client.Set(key, value, expirationTime); }
public void GetUtcExpirationTimeRelativeToNow_NoExpirationTime() { CacheOptions options = new CacheOptions(); Assert.AreEqual(DateTime.MaxValue, options.GetUtcExpirationTimeRelativeToNow()); }