Ejemplo n.º 1
0
        public void IMemory_cache_empty_remove()
        {
            //Arrange
            var cache = new DefaultMemoryStore();

            //Act
            cache.Remove(string.Empty);

            //Assert
            Assert.NotNull(cache);
        }
Ejemplo n.º 2
0
        public void Default_caching_option_with_constructor_store()
        {
            //Arrange
            var store = new DefaultMemoryStore();

            //Act
            var cachingOption = new CachingOption(store);

            //Assert
            Assert.StrictEqual(store, cachingOption.Store);
        }
Ejemplo n.º 3
0
        public void Default_caching_option_with_constructor_key_and_store()
        {
            //Arrange
            var key   = new DefaultKeyGenerator();
            var store = new DefaultMemoryStore();

            //Act
            var cachingOption = new CachingOption(key, store);

            //Assert
            Assert.StrictEqual(key, cachingOption.Key);
            Assert.StrictEqual(store, cachingOption.Store);
        }
Ejemplo n.º 4
0
        public void IMemory_cache_empty_get()
        {
            //Arrange
            var cache = new DefaultMemoryStore();

            //Act
            bool found = cache.TryGetValue(string.Empty, out var response);

            //Assert
            Assert.NotNull(cache);
            Assert.False(found);
            Assert.Null(response);
        }
Ejemplo n.º 5
0
        public void IMemory_cache_empty_key()
        {
            //Arrange
            var cache      = new DefaultMemoryStore();
            var expiration = new TimeSpan(0, 1, 0);

            var response = A.Fake <FakeCachedResponse>();

            //Act
            cache.Set(string.Empty, response, expiration);

            //Assert
            Assert.NotNull(cache);
            Assert.NotNull(response);
        }
Ejemplo n.º 6
0
        public void IMemory_cache_empty_set()
        {
            //Arrange
            var          cache      = new DefaultMemoryStore();
            var          expiration = new TimeSpan(0, 1, 0);
            const string key        = "-Random-Key-1";

            var response = A.Fake <FakeCachedResponse>();

            //Act
            cache.Set(key, response, expiration);

            //Assert
            Assert.NotNull(cache);
            Assert.NotNull(response);
        }
Ejemplo n.º 7
0
        public void IMemory_cache_with_value_set_get_with_size_limit()
        {
            //Arrange
            var          cache      = new DefaultMemoryStore(1);
            var          expiration = new TimeSpan(0, 1, 0);
            const string key        = "-Random-Key-3";

            var response = A.Fake <FakeCachedResponse>();

            //Act
            cache.Set(key, response, expiration);
            bool found = cache.TryGetValue(key, out var getResponse);

            //Assert
            Assert.Equal(response, getResponse);
            Assert.True(found);
        }
Ejemplo n.º 8
0
        public void IMemory_cache_with_value_set_remove_get()
        {
            //Arrange
            var          cache      = new DefaultMemoryStore();
            var          expiration = new TimeSpan(0, 1, 0);
            const string key        = "-Random-Key-7";

            var response = A.Fake <FakeCachedResponse>();

            //Act
            cache.Set(key, response, expiration);
            cache.Remove(key);
            bool found = cache.TryGetValue(key, out var getResponse);

            //Assert
            Assert.Null(getResponse);
            Assert.False(found);
        }