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

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

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

            //Assert
            Assert.Equal(response, getResponse);
            Assert.True(found);
        }
Ejemplo n.º 2
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.º 3
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.º 4
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);
        }