public void StoreCategoryLinksThrowsExceptionWithNullFilterTest()
        {
            var links  = Model.Create <List <Guid> >();
            var cache  = Substitute.For <IMemoryCache>();
            var config = Substitute.For <ICacheConfig>();

            var sut = new CategoryCache(cache, config);

            Action action = () => sut.StoreCategoryLinks(null, links);

            action.Should().Throw <ArgumentNullException>();
        }
        public void StoreCategoryLinksThrowsExceptionWithNullCategoryLinksTest()
        {
            var filter = Model.Create <ProfileFilter>();
            var cache  = Substitute.For <IMemoryCache>();
            var config = Substitute.For <ICacheConfig>();

            var sut = new CategoryCache(cache, config);

            Action action = () => sut.StoreCategoryLinks(filter, null);

            action.Should().Throw <ArgumentNullException>();
        }
        public void StoreCategoryLinksWritesCategoryLinksToCacheTest()
        {
            var expected    = Model.Create <List <Guid> >();
            var cacheExpiry = TimeSpan.FromMinutes(23);
            var filter      = Model.Create <ProfileFilter>();
            var cacheKey    = "CategoryLinks|" + filter.CategoryGroup + "|" + filter.CategoryName;

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

            config.CategoryLinksExpiration.Returns(cacheExpiry);
            cache.CreateEntry(cacheKey).Returns(cacheEntry);

            var sut = new CategoryCache(cache, config);

            sut.StoreCategoryLinks(filter, expected);

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