public void GetProfileResultsReturnsNullWhenCachedProfileResultsNotFoundTest() { const string CacheKey = "ProfileResults"; var cache = Substitute.For <IMemoryCache>(); var config = Substitute.For <ICacheConfig>(); object value; cache.TryGetValue(CacheKey, out value).Returns(x => false); var sut = new ProfileCache(cache, config); var actual = sut.GetProfileResults(); actual.Should().BeNull(); }
public void GetProfileResultsReturnsCachedProfileResultsTest() { var expected = Model.Create <List <ProfileResult> >(); const string CacheKey = "ProfileResults"; 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 ProfileCache(cache, config); var actual = sut.GetProfileResults(); actual.Should().BeEquivalentTo(expected); }