예제 #1
0
        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();
        }
예제 #2
0
        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);
        }