public async Task EmployerReference_Should_Not_Be_More_Than_20_Characters() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(employerRef: "123456789012345678901"); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The Reference must be 20 characters or fewer", result.Errors[0].ErrorMessage); Assert.AreEqual("EmployerReference", result.Errors[0].PropertyName); }
public async Task StartDate_is_before_DasStartDate_and_Course_Started_before_Das() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship().CourseIsEffectiveFromDate(new DateTime(2016, 1, 1)); var request = fixture.CreateValidationRequest(startYear: 2017, startMonth: 4); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual($"The start date must not be earlier than May 2017", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task Cost_Should_Not_Be_More_Than_100000() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(cost: 100001); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The total cost must be £100,000 or less", result.Errors[0].ErrorMessage); Assert.AreEqual("Cost", result.Errors[0].PropertyName); }
public async Task DateOfBirth_Should_Be_Greater_Than_Min_DateOfBirth() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(dobYear: 1899, dobMonth: 12, dobDay: 31); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual(result.Errors[0].ErrorMessage, "The Date of birth is not valid"); Assert.AreEqual("DateOfBirth", result.Errors[0].PropertyName); }
public async Task Cost_Should_Be_More_Than_zero() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(cost: 0); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("Enter the total agreed training cost", result.Errors[0].ErrorMessage); Assert.AreEqual("Cost", result.Errors[0].PropertyName); }
public async Task When_No_Change_IsMade() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(); var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("No change made", result.Errors[0].ErrorMessage); Assert.AreEqual("ApprenticeshipId", result.Errors[0].PropertyName); }
public async Task DateOfBirth_Must_Be_Younger_Than_115_At_start_of_training() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(dobYear: 1904, dobMonth: 12, dobDay: 31); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The apprentice must be younger than 115 years old at the start of their training", result.Errors[0].ErrorMessage); Assert.AreEqual("DateOfBirth", result.Errors[0].PropertyName); }
public async Task Employer_Should_Not_Be_Able_To_Change_ULN() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(uln: "555"); var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("Employer cannot modify ULN", result.Errors[0].ErrorMessage); Assert.AreEqual("ULN", result.Errors[0].PropertyName); }
public async Task When_StartDate_Overlaps() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship().SetupOverlapService(true, false); var request = fixture.CreateValidationRequest(employerRef: "abc"); var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The date overlaps with existing training dates for the same apprentice. Please check the date - contact your training provider for help", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task EndDate_Should_Not_Be_Before_Start() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(endYear: fixture.StartDate.Value.Year, endMonth: fixture.StartDate.Value.Month - 1); var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The end date must not be on or before the start date", result.Errors[0].ErrorMessage); Assert.AreEqual("EndDate", result.Errors[0].PropertyName); }
public async Task Reservation_Validations_Are_Returned() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship().SetupReservationValidationService(); var request = fixture.CreateValidationRequest(employerRef: "abc"); var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("Reason", result.Errors[0].ErrorMessage); Assert.AreEqual("CourseCode", result.Errors[0].PropertyName); }
public async Task Course_Is_Pending_On_StartDate() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship().CourseIsEffectiveFromDate(new DateTime(2020, 7, 1)); var request = fixture.CreateValidationRequest(startYear: 2020, startMonth: 6); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual($"This training course is only available to apprentices with a start date after {new DateTime(2020, 7, 1).AddMonths(-1):MM yyyy}", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task StartDate_Must_be_no_later_than_one_year_after_the_end_of_the_current_teaching_year() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var endOfCurrentTeachingYear = fixture.GetEndOfCurrentTeachingYear(); var request = fixture.CreateValidationRequest(startYear: endOfCurrentTeachingYear.AddYears(1).Year, startMonth: endOfCurrentTeachingYear.Month + 1, endYear: endOfCurrentTeachingYear.Year + 2, endMonth: endOfCurrentTeachingYear.Month); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The start date must be no later than one year after the end of the current teaching year", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task FirstName_Should_Not_Be_Empty() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(); request.FirstName = string.Empty; var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("First name must be entered", result.Errors[0].ErrorMessage); Assert.AreEqual("FirstName", result.Errors[0].PropertyName); }
public async Task EndDate_Should_Not_Be_Empty() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(); request.EndDate = null; var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The end date is not valid", result.Errors[0].ErrorMessage); Assert.AreEqual("EndDate", result.Errors[0].PropertyName); }
public async Task CourseCode_Is_Mandatory() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(); request.CourseCode = string.Empty; var result = await fixture.Validate(request); Assert.NotNull(result.Errors); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("Invalid training code", result.Errors[0].ErrorMessage); Assert.AreEqual("CourseCode", result.Errors[0].PropertyName); }
public async Task StartDate_Is_Not_With_In_FundingPeriod() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship().SetUpLastAcademicYearFundingPeriodToBeBeforeDateTimeNow(); DateTime currentAcademiceYearStartDate = fixture.GetCurrentAcademicYearStartDate(); var request = fixture.CreateValidationRequest(startYear: currentAcademiceYearStartDate.Year, startMonth: currentAcademiceYearStartDate.Month - 1); var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual($"The earliest start date you can use is {fixture.GetCurrentAcademicYearStartDate().ToGdsFormatShortMonthWithoutDay()}", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task StartDate_Is_Required() { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(); request.StartDate = null; var result = await fixture.Validate(request); Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("The start date is not valid", result.Errors[0].ErrorMessage); Assert.AreEqual("StartDate", result.Errors[0].PropertyName); }
public async Task LastName_Length_Should_Be_No_Longer_Than_100_Characters(string LastName, bool isValid) { var fixture = new EditApprenticeshipValidationServiceTestsFixture(); fixture.SetupMockContextApprenticeship(); var request = fixture.CreateValidationRequest(lastName: LastName); var result = await fixture.Validate(request); if (isValid) { Assert.AreEqual(result.Errors.Count, 0); } else { Assert.AreEqual(1, result.Errors.Count); Assert.AreEqual("You must enter a last name that's no longer than 100 characters", result.Errors[0].ErrorMessage); Assert.AreEqual("LastName", result.Errors[0].PropertyName); } }