public void ShouldBeFutureDateWithinDaysFromOffsetDate_WhenValueDateIsEqualToOffsetDate_ReturnsDateTimeValidator() { IDateTimeValidator sut = CreateSut(); DateTime offsetDate = _random.Next(100) > 50 ? DateTime.Today : DateTime.Today.AddDays(_random.Next(1, 7)); int withinDays = _random.Next(1, 7); DateTime value = offsetDate; IValidator result = sut.ShouldBeFutureDateWithinDaysFromOffsetDate(value, withinDays, offsetDate, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DateTimeValidator>()); }
public void ShouldBeFutureDateWithinDaysFromOffsetDate_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeFutureDateWithinDaysFromOffsetDate(_fixture.Create <DateTime>(), _fixture.Create <int>(), _fixture.Create <DateTime>(), GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBeFutureDateWithinDaysFromOffsetDate_WhenValueDateIsBeforeDate_ThrowsIntranetValidationException() { IDateTimeValidator sut = CreateSut(); DateTime offsetDate = _random.Next(100) > 50 ? DateTime.Today : DateTime.Today.AddDays(_random.Next(1, 7)); int withinDays = _random.Next(1, 7); DateTime value = offsetDate.AddDays(_random.Next(1, 7) * -1); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBeFutureDateWithinDaysFromOffsetDate(value, withinDays, offsetDate, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBeFutureDateWithinDaysFromOffsetDate)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBeFutureDateWithinDaysFromOffsetDate_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBeFutureDateWithinDaysFromOffsetDate(_fixture.Create <DateTime>(), _fixture.Create <int>(), _fixture.Create <DateTime>(), null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }