Beispiel #1
0
        public void IsInSegmentWithInexistentSegmentTest()
        {
            //Arrange
            var redisAdapterMock = new Mock <IRedisAdapter>();

            redisAdapterMock.Setup(x => x.SIsMember(segmentKeyPrefix + "test", "abcd")).Returns(false);

            var segmentCache = new RedisSegmentCache(redisAdapterMock.Object);

            //Act
            var result = segmentCache.IsInSegment("test", "abcd");

            //Assert
            Assert.IsFalse(result);
        }
Beispiel #2
0
        public void IsNotInSegmentOrRedisExceptionTest()
        {
            //Arrange
            var segmentName      = "segment_test";
            var redisAdapterMock = new Mock <IRedisAdapter>();

            redisAdapterMock.Setup(x => x.SIsMember(segmentKeyPrefix + segmentName, "abcd")).Returns(false);

            var segmentCache = new RedisSegmentCache(redisAdapterMock.Object);

            //Act
            var result = segmentCache.IsInSegment(segmentName, "abcd");

            //Assert
            Assert.IsFalse(result);
        }
Beispiel #3
0
        public void RemoveKeyFromSegmentTest()
        {
            //Arrange
            var segmentName = "segment_test";
            var keys        = new List <string> {
                "abcd"
            };
            var redisAdapterMock = new Mock <IRedisAdapter>();

            redisAdapterMock.Setup(x => x.SRem(segmentKeyPrefix + segmentName, It.IsAny <RedisValue[]>())).Returns(1);
            redisAdapterMock.Setup(x => x.SIsMember(segmentKeyPrefix + segmentName, "abcd")).Returns(false);

            var segmentCache = new RedisSegmentCache(redisAdapterMock.Object);

            //Act
            segmentCache.RemoveFromSegment(segmentName, keys);
            var result = segmentCache.IsInSegment(segmentName, keys.First());

            //Assert
            Assert.IsFalse(result);
        }