public void ShouldBeFutureDateOrToday_WhenValueDateIsToday_ReturnsDateTimeValidator() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Today; IValidator result = sut.ShouldBeFutureDateOrToday(value, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DateTimeValidator>()); }
public void ShouldBeFutureDateOrToday_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeFutureDateOrToday(_fixture.Create <DateTime>(), GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBeFutureDateOrToday_WhenValueDateIsBeforeToday_ThrowsIntranetValidationException() { IDateTimeValidator sut = CreateSut(); DateTime value = DateTime.Today.AddDays(_random.Next(1, 7) * -1); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeFutureDateOrToday(value, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBeFutureDateOrToday)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeFutureDateOrToday_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeFutureDateOrToday(_fixture.Create <DateTime>(), null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }