Exemplo n.º 1
0
        public async Task Remove_GivenEmptyStore_WhenItemAddedThenRemoved_ThenTheKeyMustBeFoundButEmpty()
        {
            // arrange
            var entity = new TestType1Entity {
                Name = "test1_1", Id = "1"
            };

            // act
            await _cacheType1.AddOrUpdate(entity);

            await _cacheType1.Remove(entity.Id);

            var allKeys =
                _connection.GetEndPoints()
                .SelectMany(
                    endPoint => _connection.GetServer(endPoint).Keys().Select(key => key.ToString()).ToArray())
                .ToArray();

            // assert
            Assert.That(allKeys, Is.Not.Empty);
        }
Exemplo n.º 2
0
        public void Redis_cache_set_remove_get()
        {
            //Arrange
            var expirationDate = DateTime.UtcNow.AddMinutes(15);
            var cache          = new RedisCacheStore(LOCALHOST);
            var context        = new NancyContext()
            {
                Response = new FakeResponse()
                {
                }
            };

            //Act
            cache.Set(TEST_KEY_2, context, expirationDate);

            cache.Remove(TEST_KEY_2);

            var response = cache.Get(TEST_KEY_2);

            //Assert
            Assert.Null(response);
            Assert.NotNull(context.Response);
        }
Exemplo n.º 3
0
        public void Redis_cache_set_remove_get(string localhost, string key)
        {
            //Arrange
            var expirationDate = DateTime.UtcNow.AddMinutes(15);
            var cache          = new RedisCacheStore(localhost);
            var context        = new NancyContext()
            {
                Response = new FakeResponse()
                {
                }
            };

            //Act
            cache.Set(key, context, expirationDate);

            cache.Remove(key);

            var response = cache.Get(key);

            //Assert
            Assert.Null(response);
            Assert.NotNull(context.Response);
        }