public void ShouldBePastDateTime_WhenValueDateTimeIsNow_ReturnsDateTimeValidator() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Now; IValidator result = sut.ShouldBePastDateTime(value, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DateTimeValidator>()); }
public void ShouldBePastDateTime_WhenValueDateTimeIsBeforeNow_ReturnsDateTimeValidator() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Now.AddSeconds(_random.Next(5, 30) * -1); IValidator result = sut.ShouldBePastDateTime(value, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DateTimeValidator>()); }
public void ShouldBePastDateTime_WhenValueDateTimeIsAfterNow_ThrowsIntranetValidationException() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Now.AddSeconds(_random.Next(5, 30)); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBePastDateTime(value, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBePastDateTime)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBePastDateTime_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBePastDateTime(_fixture.Create <DateTime>(), GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBePastDateTime_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBePastDateTime(_fixture.Create <DateTime>(), null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }