public void UpdateCacheEntryOptions_SetsCachePreservationPriority() { // Arrange var priority = CacheItemPriority.High; var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { Priority = priority }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(priority, cacheEntryOptions.Priority); }
public void UpdateCacheEntryOptions_SetsSlidingExpiration_IfExpiresSlidingIsSet() { // Arrange var expiresSliding = TimeSpan.FromSeconds(37); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresSliding = expiresSliding }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresSliding, cacheEntryOptions.SlidingExpiration); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresAfterIsSet() { // Arrange var expiresAfter = TimeSpan.FromSeconds(42); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresAfter = expiresAfter }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresAfter, cacheEntryOptions.AbsoluteExpirationRelativeToNow); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresOnIsSet() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresOn = expiresOn }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }
public void UpdateCacheEntryOptions_UsesAbsoluteExpirationSpecifiedOnEntryLink() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(7); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }
public void UpdateCacheEntryOptions_CopiesTriggersFromEntryLink() { // Arrange var expiresSliding = TimeSpan.FromSeconds(30); var expected = new[] { Mock.Of <IExpirationTrigger>(), Mock.Of <IExpirationTrigger>() }; var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresSliding = expiresSliding }; var entryLink = new EntryLink(); entryLink.AddExpirationTriggers(expected); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expected, cacheEntryOptions.Triggers.ToArray()); }
public void UpdateCacheEntryOptions_PrefersAbsoluteExpirationSpecifiedOnEntryLinkOverExpiresOn() { // Arrange var expiresOn1 = DateTimeOffset.UtcNow.AddDays(12); var expiresOn2 = DateTimeOffset.UtcNow.AddMinutes(4); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresOn = expiresOn1 }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn2); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn2, cacheEntryOptions.AbsoluteExpiration); }
public void UpdateCacheEntryOptions_CopiesTriggersFromEntryLink() { // Arrange var expiresSliding = TimeSpan.FromSeconds(30); var expected = new[] { Mock.Of<IExpirationTrigger>(), Mock.Of<IExpirationTrigger>() }; var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresSliding = expiresSliding }; var entryLink = new EntryLink(); entryLink.AddExpirationTriggers(expected); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expected, cacheEntryOptions.Triggers.ToArray()); }
public void UpdateCacheEntryOptions_SetsCachePreservationPriority() { // Arrange var priority = CacheItemPriority.High; var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { Priority = priority }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(priority, cacheEntryOptions.Priority); }
public void UpdateCacheEntryOptions_SetsSlidingExpiration_IfExpiresSlidingIsSet() { // Arrange var expiresSliding = TimeSpan.FromSeconds(37); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresSliding = expiresSliding }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresSliding, cacheEntryOptions.SlidingExpiration); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresAfterIsSet() { // Arrange var expiresAfter = TimeSpan.FromSeconds(42); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresAfter = expiresAfter }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresAfter, cacheEntryOptions.AbsoluteExpirationRelativeToNow); }
public void UpdateCacheEntryOptions_PrefersAbsoluteExpirationSpecifiedOnEntryLinkOverExpiresOn() { // Arrange var expiresOn1 = DateTimeOffset.UtcNow.AddDays(12); var expiresOn2 = DateTimeOffset.UtcNow.AddMinutes(4); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresOn = expiresOn1 }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn2); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn2, cacheEntryOptions.AbsoluteExpiration); }
public void UpdateCacheEntryOptions_UsesAbsoluteExpirationSpecifiedOnEntryLink() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(7); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { }; var entryLink = new EntryLink(); entryLink.SetAbsoluteExpiration(expiresOn); // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(entryLink); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }
public void UpdateCacheEntryOptions_SetsAbsoluteExpiration_IfExpiresOnIsSet() { // Arrange var expiresOn = DateTimeOffset.UtcNow.AddMinutes(4); var cache = new MemoryCache(new MemoryCacheOptions()); var cacheTagHelper = new CacheTagHelper(cache) { ExpiresOn = expiresOn }; // Act var cacheEntryOptions = cacheTagHelper.GetMemoryCacheEntryOptions(new EntryLink()); // Assert Assert.Equal(expiresOn, cacheEntryOptions.AbsoluteExpiration); }