Example #1
0
        public void GetChangeNumberWhenNotSetOrRedisExceptionTest()
        {
            //Arrange
            var changeNumber     = -1;
            var segmentName      = "segment_test";
            var redisAdapterMock = new Mock <IRedisAdapter>();

            redisAdapterMock.Setup(x => x.Get(segmentNameKeyPrefix.Replace("{segmentname}", segmentName) + "till")).Returns("");
            var segmentCache = new RedisSegmentCache(redisAdapterMock.Object);

            //Act
            var result = segmentCache.GetChangeNumber(segmentName);

            //Assert
            Assert.AreEqual(changeNumber, result);
        }
Example #2
0
        public void SetAndGetChangeNumberTest()
        {
            //Arrange
            var changeNumber     = 1234;
            var segmentName      = "segment_test";
            var redisAdapterMock = new Mock <IRedisAdapter>();

            redisAdapterMock.Setup(x => x.Set(segmentNameKeyPrefix.Replace("{segmentname}", segmentName) + "till", changeNumber.ToString())).Returns(true);
            redisAdapterMock.Setup(x => x.Get(segmentNameKeyPrefix.Replace("{segmentname}", segmentName) + "till")).Returns(changeNumber.ToString());
            var segmentCache = new RedisSegmentCache(redisAdapterMock.Object);

            //Act
            segmentCache.SetChangeNumber(segmentName, 1234);
            var result = segmentCache.GetChangeNumber(segmentName);

            //Assert
            Assert.AreEqual(1234, result);
        }