public void UpdateCacheEntryOptions_DefaultsTo30SecondsSliding_IfNoEvictionCriteriaIsProvided() { // Arrange var slidingExpiresIn = TimeSpan.FromSeconds(30); var storage = GetStorage(); var service = new DistributedCacheTagHelperService( storage, Mock.Of <IDistributedCacheTagHelperFormatter>(), new HtmlTestEncoder(), NullLoggerFactory.Instance ); var cacheTagHelper = new DistributedCacheTagHelper( service, new HtmlTestEncoder()); // Act var cacheEntryOptions = cacheTagHelper.GetDistributedCacheEntryOptions(); // Assert Assert.Equal(slidingExpiresIn, cacheEntryOptions.SlidingExpiration); }
public void UpdateCacheEntryOptions_SetsSlidingExpiration_IfExpiresSlidingIsSet() { // Arrange var expiresSliding = TimeSpan.FromSeconds(37); var storage = GetStorage(); var service = new DistributedCacheTagHelperService( storage, Mock.Of <IDistributedCacheTagHelperFormatter>(), new HtmlTestEncoder(), NullLoggerFactory.Instance ); var cacheTagHelper = new DistributedCacheTagHelper( service, new HtmlTestEncoder()) { ExpiresSliding = expiresSliding }; // Act var cacheEntryOptions = cacheTagHelper.GetDistributedCacheEntryOptions(); // Assert Assert.Equal(expiresSliding, cacheEntryOptions.SlidingExpiration); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresAfterIsSet() { // Arrange var expiresAfter = TimeSpan.FromSeconds(42); var storage = GetStorage(); var service = new DistributedCacheTagHelperService( storage, Mock.Of <IDistributedCacheTagHelperFormatter>(), new HtmlTestEncoder(), NullLoggerFactory.Instance ); var cacheTagHelper = new DistributedCacheTagHelper( service, new HtmlTestEncoder()) { ExpiresAfter = expiresAfter }; // Act var cacheEntryOptions = cacheTagHelper.GetDistributedCacheEntryOptions(); // Assert Assert.Equal(expiresAfter, cacheEntryOptions.AbsoluteExpirationRelativeToNow); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresOnIsSet() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4); var storage = GetStorage(); var service = new DistributedCacheTagHelperService( storage, Mock.Of <IDistributedCacheTagHelperFormatter>(), new HtmlTestEncoder(), NullLoggerFactory.Instance ); var cacheTagHelper = new DistributedCacheTagHelper( service, new HtmlTestEncoder()) { ExpiresOn = expiresOn }; // Act var cacheEntryOptions = cacheTagHelper.GetDistributedCacheEntryOptions(); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }