コード例 #1
0
        public void ExpiretionSlidingModeWithMaxExpireDateHasChangedAfterCheckExpire(DateTimeOffset expireDate, TimeSpan slidingSize, DateTimeOffset maxExpireDate)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxExpireDate);

            testObject.CheckExpire(fakeNowDate, out var resultEffective);
            Assert.NotEqual(testObject.expireInfo.expireDate, resultEffective.expireDate);
        }
コード例 #2
0
        public void CreateExpirationCalculationSlidingMode(DateTimeOffset expireDate, TimeSpan slidingSize, uint maxCount)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxCount);

            Assert.Equal(ExpirationMode.Sliding, testObject.mode);
            Assert.Equal(testObject.initail, testObject.expireInfo.expireDate);
        }
コード例 #3
0
        public void ExpirationSlidingModeMaxCountIsZeroCheckAndChange(DateTimeOffset expireDate, TimeSpan slidingSize, uint maxCount)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxCount);

            testObject.CheckExpire(fakeNowDate, out var resultEffective);
            Assert.NotEqual(testObject.expireInfo.expireDate, resultEffective.expireDate);
        }
コード例 #4
0
        public void ExpiretionAbsoluteModeHasNotChangedAfterCheckExpire(DateTimeOffset expireDate)
        {
            var testObject = new ExpirationCalculation(expireDate);

            testObject.CheckExpire(fakeNowDate, out var resultEffective);
            Assert.Equal(testObject.expireInfo.expireDate, resultEffective.expireDate);
        }
コード例 #5
0
        public void ExpirationSlidingModeNotExpire(DateTimeOffset expireDate, TimeSpan slidingSize, uint maxCount)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxCount);
            var result     = testObject.CheckExpire(fakeNowDate, out var resultEffective);

            Assert.False(result);
        }
コード例 #6
0
        public void ExpirationAbsoluteModeNotExpire(DateTimeOffset expireDate)
        {
            var testObject = new ExpirationCalculation(expireDate);
            var result     = testObject.CheckExpire(fakeNowDate, out var resultEffective);

            Assert.False(result);
        }
コード例 #7
0
        public void CreateExpirationCalculationSlidingModeWithMaxExpireDate(DateTimeOffset expireDate, TimeSpan slidingSize, DateTimeOffset maxExpireDate)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxExpireDate);

            Assert.Equal(ExpirationMode.Sliding, testObject.mode);
            Assert.Equal(0, (int)testObject.maxCount);
            Assert.NotNull(testObject.maxExpireDate);
        }
コード例 #8
0
        public void ExpirationSlidingModeSetMaxExpireDateWithZeroSlidingSizeCheckAndChange(DateTimeOffset expireDate, TimeSpan slidingSize, DateTimeOffset maxExpireDate)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxExpireDate);

            testObject.CheckExpire(fakeNowDate, out var resultEffective);
            Assert.Equal(TimeSpan.Zero, testObject.slidingSize);
            Assert.Equal(testObject.expireInfo.expireDate, resultEffective.expireDate);
        }
コード例 #9
0
        public void CreateExpirationCalculationSlidingModeWithMaxCountAndSlidingSize(DateTimeOffset expireDate, TimeSpan slidingSize, uint maxCount)
        {
            var testObject = new ExpirationCalculation(expireDate, slidingSize, maxCount);

            Assert.Equal(ExpirationMode.Sliding, testObject.mode);
            Assert.NotEqual(testObject.initail, testObject.maxExpireDate);
            Assert.NotEqual(0, (int)testObject.maxCount);
            Assert.NotEqual(TimeSpan.Zero, testObject.slidingSize);
        }
コード例 #10
0
        public void CreateExpirationCalculationAbsoluteMode(DateTimeOffset expireDate)
        {
            var testObject = new ExpirationCalculation(expireDate);

            Assert.Equal(ExpirationMode.Absolute, testObject.mode);
            Assert.Equal(testObject.initail, testObject.expireInfo.expireDate);
            Assert.Equal(testObject.maxExpireDate, testObject.initail);
            Assert.Equal(0, (int)testObject.maxCount);
        }
コード例 #11
0
        public void ExpirationSlidingModeMaxCountMoreThanOrEqualMaxCount(DateTimeOffset expireDate, TimeSpan slidingSize, uint maxCount)
        {
            var       testObject      = new ExpirationCalculation(expireDate, slidingSize, maxCount);
            var       count           = rnd.Next((int)maxCount, (int)maxCount + 10);
            Effective resultEffective = new Effective(testObject.expireInfo.expireDate);

            for (int i = 0; i < count; i++)
            {
                testObject.CheckExpire(fakeNowDate, out resultEffective);
                testObject.expireInfo = new Effective(resultEffective.expireDate);
            }
            Assert.Equal(testObject.maxExpireDate, resultEffective.expireDate);
        }