public void ThrowsIfAbsoluteTimeoutIsInvalid(TimeSpan invalidTimeout) { var builder = new TimeoutSettingsBuilder().AbsoluteTimeout(invalidTimeout); Assert.Throws <InvalidOperationException>(() => { var unusedResult = builder.Build(); }); }
public void ThrowsIfAbsoluteTimeoutIsLessThanIdleTimeout() { var absoluteTimeout = TimeSpan.FromDays(1); var idleTimeout = TimeSpan.FromDays(2); var builder = new TimeoutSettingsBuilder() .AbsoluteTimeout(absoluteTimeout) .IdleTimeout(idleTimeout); Assert.Throws <InvalidOperationException>(() => { var unusedResult = builder.Build(); }); }
public void UsesProvidedValues() { var idleTimeout = TimeSpan.FromDays(1); var absoluteTimeout = TimeSpan.FromDays(2); var expectedSettings = new TimeoutSettings(idleTimeout, absoluteTimeout); var settings = new TimeoutSettingsBuilder() .IdleTimeout(idleTimeout) .AbsoluteTimeout(absoluteTimeout) .Build(); Assert.Equal(expectedSettings, settings); }
public void ReturnsCorrectExpiration(TestParameters parameters) { var session = CreateRawSession(parameters.CreationDate); var settings = new TimeoutSettingsBuilder() .IdleTimeout(parameters.IdleTimeout) .AbsoluteTimeout(parameters.AbsoluteTimeout) .Build(); var dateTimeFactory = new Mock <IDateTimeFactory>(); dateTimeFactory.Setup(f => f.Now()) .Returns(parameters.Today); var expirationRetriever = new ExpirationRetriever(dateTimeFactory.Object, settings); Assert.Equal(parameters.ExpectedExpiration, expirationRetriever.GetExpiration(session)); }
public void BuilderHasDefaultValues() { var unusedResult = new TimeoutSettingsBuilder().Build(); }