public void Then_the_error_lines_are_reported_for_the_invalid_date_when_multiple_start_dates_are_submitted() { // Arrange _request.EmploymentStartDateDays.AddRange(new List <int?> { 5, 0, 20, 1 }); _request.EmploymentStartDateMonths.AddRange(new List <int?> { 10, 8, 5, 0 }); _request.EmploymentStartDateYears.AddRange(new List <int?> { 2021, 2021, 2021, 2021 }); var validator = new EmploymentStartDateValidator(); // Act var result = validator.Validate(_request).ToList(); // Assert result.Count.Should().Be(2); result[0].Index.Should().Be(1); result[0].ValidationMessage.Should().Be(EmploymentStartDateValidator.InvalidFieldErrorMessage); result[1].Index.Should().Be(3); result[1].ValidationMessage.Should().Be(EmploymentStartDateValidator.InvalidFieldErrorMessage); result.FirstOrDefault(x => x.Index == 0).Should().BeNull(); result.FirstOrDefault(x => x.Index == 2).Should().BeNull(); }
public void Then_error_is_returned_if_no_dates_present() { var validator = new EmploymentStartDateValidator(); // Act var result = validator.Validate(_request).ToList(); // Assert result.Count.Should().Be(1); result[0].Index.Should().Be(0); result[0].ValidationMessage.Should().Be(EmploymentStartDateValidator.InvalidFieldErrorMessage); }
public void Then_errors_are_returned_if_any_of_the_date_fields_are_empty(int day, int month, int year) { // Arrange _request.EmploymentStartDateDays.Add(day); _request.EmploymentStartDateMonths.Add(month); _request.EmploymentStartDateYears.Add(year); var validator = new EmploymentStartDateValidator(); // Act var result = validator.Validate(_request).ToList(); // Assert result.Count.Should().Be(1); result[0].Index.Should().Be(0); result[0].ValidationMessage.Should().Be(EmploymentStartDateValidator.InvalidFieldErrorMessage); }
public void Then_error_is_returned_for_invalid_year() { // Arrange _request.EmploymentStartDateDays.Add(1); _request.EmploymentStartDateMonths.Add(12); _request.EmploymentStartDateYears.Add(2019); var validator = new EmploymentStartDateValidator(); // Act var result = validator.Validate(_request).ToList(); // Assert result.Count.Should().Be(1); result[0].Index.Should().Be(0); result[0].ValidationMessage.Should().Be(EmploymentStartDateValidator.InvalidFieldErrorMessage); }