Exemple #1
0
        public void StoreProfileResultsThrowsExceptionWithNullProfileResultsTest()
        {
            var cache  = Substitute.For <IMemoryCache>();
            var config = Substitute.For <ICacheConfig>();

            var sut = new ProfileCache(cache, config);

            Action action = () => sut.StoreProfileResults(null);

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #2
0
        public void StoreProfileResultsWritesProfileResultsToCacheTest()
        {
            var          expected    = Model.Create <List <ProfileResult> >();
            var          cacheExpiry = TimeSpan.FromMinutes(23);
            const string CacheKey    = "ProfileResults";

            var cache      = Substitute.For <IMemoryCache>();
            var config     = Substitute.For <ICacheConfig>();
            var cacheEntry = Substitute.For <ICacheEntry>();

            config.ProfileResultsExpiration.Returns(cacheExpiry);
            cache.CreateEntry(CacheKey).Returns(cacheEntry);

            var sut = new ProfileCache(cache, config);

            sut.StoreProfileResults(expected);

            cacheEntry.Value.Should().Be(expected);
            cacheEntry.SlidingExpiration.Should().Be(cacheExpiry);
        }