public void StoreCategoriesThrowsExceptionWithNullCategoriesTest()
        {
            var cache  = Substitute.For <IMemoryCache>();
            var config = Substitute.For <ICacheConfig>();

            var sut = new CategoryCache(cache, config);

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

            action.Should().Throw <ArgumentNullException>();
        }
        public void StoreCategoriesWritesCategoriesToCacheTest()
        {
            var          expected    = Model.Create <List <Category> >();
            var          cacheExpiry = TimeSpan.FromMinutes(23);
            const string CacheKey    = "Categories";

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

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

            var sut = new CategoryCache(cache, config);

            sut.StoreCategories(expected);

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