public void ShouldBePastDateWithinDaysFromOffsetDate_WhenValueDateIsEqualToDaysBeforeOffsetDate_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.AddDays(withinDays * -1); IValidator result = sut.ShouldBePastDateWithinDaysFromOffsetDate(value, withinDays, offsetDate, GetType(), _fixture.Create <string>()); Assert.That(result, Is.TypeOf <BusinessLogic.Validation.DateTimeValidator>()); }
public void ShouldBePastDateWithinDaysFromOffsetDate_WhenValidatingFieldIsWhiteSpace_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBePastDateWithinDaysFromOffsetDate(_fixture.Create <DateTime>(), _fixture.Create <int>(), _fixture.Create <DateTime>(), GetType(), " ")); Assert.That(result.ParamName, Is.EqualTo("validatingField")); }
public void ShouldBePastDateWithinDaysFromOffsetDate_WhenValueDateIsBeforeDaysBeforeOffsetDate_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((withinDays + _random.Next(1, 7)) * -1); Type validatingType = GetType(); string validatingField = _fixture.Create <string>(); IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.ShouldBePastDateWithinDaysFromOffsetDate(value, withinDays, offsetDate, validatingType, validatingField)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueShouldBePastDateWithinDaysFromOffsetDate)); Assert.That(result.ValidatingType, Is.EqualTo(validatingType)); Assert.That(result.ValidatingField, Is.EqualTo(validatingField)); }
public void ShouldBePastDateWithinDaysFromOffsetDate_WhenValidatingTypeIsNull_ThrowsArgumentNullException() { IDateTimeValidator sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ShouldBePastDateWithinDaysFromOffsetDate(_fixture.Create <DateTime>(), _fixture.Create <int>(), _fixture.Create <DateTime>(), null, _fixture.Create <string>())); Assert.That(result.ParamName, Is.EqualTo("validatingType")); }