public void Should_dispose_existing_phoenix() { var key = "theCacheKey" + Guid.NewGuid(); // Arrange var objCacheItem = new CacheItem { MaxAge = 5, StaleWhileRevalidate = 5, StoreId = 1000, CreatedTime = DateTime.UtcNow.AddSeconds(-5).AddMilliseconds(-1), Key = key }; var existingPhoenix = Substitute.For <Phoenix>(Substitute.For <_IInvocation>(), objCacheItem); var att = new OutputCacheAttributeWithPublicMethods { Duration = 5, CacheStoreId = 1000, StaleWhileRevalidate = 5 }; Global.Cache.PhoenixFireCage[key] = existingPhoenix; // Action att.CreatePhoenixPublic(Substitute.For <_IInvocation>(), objCacheItem); // Assert Assert.That(Global.Cache.PhoenixFireCage[key] is Phoenix); existingPhoenix.Received(1).Dispose(); }
public void Should_dispose_existing_phoenix() { var key = "theCacheKey" + Guid.NewGuid(); // Arrange var objCacheItem = new CacheItem { MaxAge = 5, StaleWhileRevalidate = 5, StoreId = 1000, CreatedTime = DateTime.UtcNow.AddSeconds(-5).AddMilliseconds(-1), Key = key }; var existingPhoenix = Substitute.For<Phoenix>(Substitute.For<_IInvocation>(), objCacheItem); var att = new OutputCacheAttributeWithPublicMethods { Duration = 5, CacheStoreId = 1000, StaleWhileRevalidate = 5 }; Global.Cache.PhoenixFireCage[key] = existingPhoenix; // Action att.CreatePhoenixPublic(Substitute.For<_IInvocation>(), objCacheItem); // Assert Assert.That(Global.Cache.PhoenixFireCage[key] is Phoenix); existingPhoenix.Received(1).Dispose(); }