public void GetCategoryLinksReturnsCachedCategoryLinksTest() { var filter = Model.Create <ProfileFilter>(); var expected = Model.Create <List <Guid> >(); var cacheKey = "CategoryLinks|" + filter.CategoryGroup + "|" + filter.CategoryName; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns( x => { x[1] = expected; return(true); }); var sut = new CategoryCache(cache, config); var actual = sut.GetCategoryLinks(filter); actual.Should().BeEquivalentTo(expected); }
public void GetCategoryLinksThrowsExceptionWithNullFilterTest() { var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); var sut = new CategoryCache(cache, config); Action action = () => sut.GetCategoryLinks(null); action.Should().Throw <ArgumentNullException>(); }
public void GetCategoryLinksReturnsNullWhenCachedCategoryLinksNotFoundTest() { var filter = Model.Create <ProfileFilter>(); var cacheKey = "CategoryLinks|" + filter.CategoryGroup + "|" + filter.CategoryName; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(cacheKey, out value).Returns(x => false); var sut = new CategoryCache(cache, config); var actual = sut.GetCategoryLinks(filter); actual.Should().BeNull(); }