public void ShouldUseDefaultMemoryCache() { // Arrange var sut = new MemoryCache(); // Act var result = sut.Cache; // Assert Expect(result) .To.Be(System.Runtime.Caching.MemoryCache.Default); }
public void ShouldSetUpNamedCacheWithSettings() { // Arrange var name = GetRandomString(); var cacheSizeInMb = GetRandomInt(5, 50); var memoryLimit = GetRandomInt(50, 80); var pollingInterval = TimeSpan.FromSeconds(GetRandomInt(10, 20)); var sut = new MemoryCache( name, cacheSizeInMb, memoryLimit, pollingInterval); // Act var actual = sut.Cache as System.Runtime.Caching.MemoryCache; // Assert Expect(actual).Not.To.Be.Null(); Expect(actual.Name).To.Equal(name); Expect(actual.PollingInterval).To.Equal(pollingInterval); Expect(actual.CacheMemoryLimit).To.Equal(cacheSizeInMb * 1024 * 1024); Expect(actual.PhysicalMemoryLimit).To.Equal(memoryLimit); }