Exemple #1
0
        public void StoreProfileThrowsExceptionWithNullProfileTest()
        {
            var cache  = Substitute.For <IMemoryCache>();
            var config = Substitute.For <ICacheConfig>();

            var sut = new ProfileCache(cache, config);

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

            action.Should().Throw <ArgumentNullException>();
        }
Exemple #2
0
        public void StoreProfileWritesProfileToCacheTest()
        {
            var expected    = Model.Create <Profile>();
            var cacheExpiry = TimeSpan.FromMinutes(23);
            var cacheKey    = "Profile|" + expected.Id;

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

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

            var sut = new ProfileCache(cache, config);

            sut.StoreProfile(expected);

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