public void HasReachedLimit_NumberOfRecordsBelowLimit_ReturnsFalse() { //Arrange var records = new[] { new VerificationRecord("pseudo-1", DateTime.UtcNow.AddHours(-23)), new VerificationRecord("pseudo-1", DateTime.UtcNow.AddHours(-21)) }; var config = new VerificationLimitConfig { MaxLimitDuration = TimeSpan.FromHours(24), MaxVerificationsAllowed = 3 }; var automocker = new AutoMocker(); automocker.SetupOptions(config); var target = automocker.CreateInstance <VerificationLimit>(); //Act var result = target.HasReachedLimit(records); //Assert result.Should().BeFalse(); }
public void Config_ReturnsActiveConfig() { //Arrange var config = new VerificationLimitConfig(); var automocker = new AutoMocker(); automocker.SetupOptions(config); var target = automocker.CreateInstance <VerificationLimit>(); //Act var result = target.Config; //Assert result.Should().Be(config); }
public void RecordsCutoff_GivenDurationConfig_ReturnsUtcNowMinusDuration() { //Arrange var limitDuration = TimeSpan.FromHours(3); var config = new VerificationLimitConfig { MaxLimitDuration = limitDuration }; var automocker = new AutoMocker(); automocker.SetupOptions(config); var target = automocker.CreateInstance <VerificationLimit>(); //Act var testStart = DateTime.UtcNow; var result = target.RecordsCutoff; var testEnd = DateTime.UtcNow; //Assert result.Should().BeAfter(testStart - limitDuration).And.BeBefore(testEnd - limitDuration); }