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); }
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); }
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); }
public void ExpiretionAbsoluteModeHasNotChangedAfterCheckExpire(DateTimeOffset expireDate) { var testObject = new ExpirationCalculation(expireDate); testObject.CheckExpire(fakeNowDate, out var resultEffective); Assert.Equal(testObject.expireInfo.expireDate, resultEffective.expireDate); }
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); }
public void ExpirationAbsoluteModeNotExpire(DateTimeOffset expireDate) { var testObject = new ExpirationCalculation(expireDate); var result = testObject.CheckExpire(fakeNowDate, out var resultEffective); Assert.False(result); }
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); }
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); }
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); }
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); }
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); }