Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,5 @@ public int? Cost
}
public string EPAOrgId { get; set; }

public bool? RecognisePriorLearning { get; set; }

public int? DurationReducedBy { get; set; }

public int? PriceReducedBy { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AutoFixture;
using FluentAssertions;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -288,17 +287,6 @@ public void ValidateError(BulkUploadValidateApiResponse errors, int numberOfErro
Assert.AreEqual(property, errors.BulkUploadValidationErrors[0].Errors[0].Property);
}

public void ValidateError(BulkUploadValidateApiResponse errors, string property, string errorText)
{
errors.Should().NotBeNull();
errors.BulkUploadValidationErrors.Should().NotBeEmpty();
errors.BulkUploadValidationErrors[0].Errors.Should().ContainEquivalentOf(new
{
Property = property,
ErrorText = errorText,
});
}

internal BulkUploadValidateCommandHandlerTestsFixture SetCohortRef(string cohortRef)
{
CsvRecords[0].CohortRef = cohortRef;
Expand Down Expand Up @@ -456,13 +444,6 @@ internal void SetOverlappingEmailWithinTheSameCohort(OverlapStatus status)

}

internal void SetPriorLearning(bool? recognisePriorLearning, int? durationReducedBy = null, int? priceReducedBy = null)
{
CsvRecords[0].RecognisePriorLearning = recognisePriorLearning;
CsvRecords[0].DurationReducedBy = durationReducedBy;
CsvRecords[0].PriceReducedBy = priceReducedBy;
}

internal void SetUpIncompleteRecord()
{
DraftApprenticeship = new DraftApprenticeship
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentAssertions;
using NUnit.Framework;
using NUnit.Framework;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -32,39 +31,4 @@ public async Task Reservation_Validation_Error_Gets_Added_To_Correct_Row()
Assert.IsTrue(errors.BulkUploadValidationErrors.All(x => x.RowNumber == 1));
}
}

[Ignore("RPL cannot be mandatory in bulk upload until all Providers' software systems are updated", Until = "2022-10-30")]
public class PriorLearningValidationTests
{
[Test]
public async Task Prior_Learning_Validation_Error()
{
var fixture = new BulkUploadValidateCommandHandlerTestsFixture();
fixture.SetPriorLearning(recognisePriorLearning: null);

var errors = await fixture.Handle();

fixture.ValidateError(errors, "RecognisePriorLearning", "Enter whether <b>prior learning</b> is recognised.");
}

[Test]
public async Task Prior_Learning_Duration_Validation_Error()
{
var fixture = new BulkUploadValidateCommandHandlerTestsFixture();
fixture.SetPriorLearning(recognisePriorLearning: true, durationReducedBy: null, priceReducedBy: 1);

var errors = await fixture.Handle();
fixture.ValidateError(errors, "DurationReducedBy", "Enter the <b>duration</b> this apprenticeship has been reduced by due to prior learning.");
}

[Test]
public async Task Prior_Learning_Price_Validation_Error()
{
var fixture = new BulkUploadValidateCommandHandlerTestsFixture();
fixture.SetPriorLearning(recognisePriorLearning: true, durationReducedBy: 1, priceReducedBy: null);

var errors = await fixture.Handle();
fixture.ValidateError(errors, "PriceReducedBy", "Enter the <b>price</b> this apprenticeship has been reduced by due to prior learning.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Task Handle_WhenAccountLegalEntityHasAlreadyBeenDeleted_ThenShouldThrowEx
{
return TestExceptionAsync(f => f.SetAccountLegalEntityDeletedBeforeCommand(),
f => f.Handle(),
(f, r) => r.Should().ThrowAsync<InvalidOperationException>());
(f, r) => r.Should().Throw<InvalidOperationException>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task Handle_WhenHandlingCommand_ThrowErrorWhenNoEmailAddress()
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = "Invitation cannot be sent as there is no email associated with apprenticeship" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = "Invitation cannot be sent as there is no email associated with apprenticeship" });
}

[Test]
Expand All @@ -99,7 +99,7 @@ public async Task Handle_WhenHandlingCommand_ThrowErrorWhenEmailAddressHasBeenCo
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = "Email address has been confirmed" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = "Email address has been confirmed" });
}

private async Task<Apprenticeship> SetupApprenticeship(Party party = Party.Employer, string email = null, bool? emailAddressConfirmed = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task Handle_WhenHandlingCommand_ThrowErrorForNonPausedApprenticeshi
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = "Only paused record can be activated" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = "Only paused record can be activated" });
}

[Test]
Expand All @@ -122,7 +122,7 @@ public async Task Handle_WhenHandlingCommand_ThrowDomainExceptionIfPartyIsNotEmp
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = $"Only employers are allowed to edit the end of completed records - {party} is invalid" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = $"Only employers are allowed to edit the end of completed records - {party} is invalid" });
}

private async Task<Apprenticeship> SetupApprenticeship(Party party = Party.Employer, PaymentStatus paymentStatus = PaymentStatus.Paused, DateTime? startDate = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public async Task Handle_WhenHandlingCommand_WithInvalidCallingParty_ThenShouldT
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = "StopApprenticeship is restricted to Employers only - Provider is invalid" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = "StopApprenticeship is restricted to Employers only - Provider is invalid" });
}

[Test]
Expand All @@ -135,7 +135,7 @@ public async Task Handle_WhenHandlingCommand_WithInvalidApprenticeshipForStop_Pa
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "PaymentStatus", ErrorMessage = "Apprenticeship must be Active or Paused. Unable to stop apprenticeship" });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "PaymentStatus", ErrorMessage = "Apprenticeship must be Active or Paused. Unable to stop apprenticeship" });
}

[Test, MoqAutoData]
Expand All @@ -150,7 +150,7 @@ public async Task Handle_WhenHandlingCommand_WithMismatchedAccountId_ThenShouldT
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "accountId", ErrorMessage = $"Employer {command.AccountId} not authorised to access commitment {apprenticeship.Cohort.Id}, expected employer {apprenticeship.Cohort.EmployerAccountId}" });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "accountId", ErrorMessage = $"Employer {command.AccountId} not authorised to access commitment {apprenticeship.Cohort.Id}, expected employer {apprenticeship.Cohort.EmployerAccountId}" });
}

[Test, MoqAutoData]
Expand All @@ -164,7 +164,7 @@ public async Task Handle_WhenHandlingCommand_WithApprenticeshipWaitingToStart_Wi
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "stopDate", ErrorMessage = $"Invalid stop date. Date should be value of start date if training has not started." });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "stopDate", ErrorMessage = $"Invalid stop date. Date should be value of start date if training has not started." });
}

[Test, MoqAutoData]
Expand All @@ -179,7 +179,7 @@ public async Task Handle_WhenHandlingCommand_WhenValidatingApprenticeship_WithSt
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "stopDate", ErrorMessage = $"Invalid Stop Date. Stop date cannot be in the future and must be the 1st of the month." });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "stopDate", ErrorMessage = $"Invalid Stop Date. Stop date cannot be in the future and must be the 1st of the month." });
}

[Test, MoqAutoData]
Expand All @@ -194,7 +194,7 @@ public async Task Handle_WhenHandlingCommand_WhenValidatingApprenticeship_WithSt
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "stopDate", ErrorMessage = $"Invalid Stop Date. Stop date cannot be before the apprenticeship has started." });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "stopDate", ErrorMessage = $"Invalid Stop Date. Stop date cannot be before the apprenticeship has started." });
}

[Test, MoqAutoData]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task Handle_WhenHandlingCommand_WithInvalidCallingParty_ThenShouldT
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { ErrorMessage = "UpdateApprenticeshipStopDate is restricted to Employers only - Provider is invalid" });
exception.DomainErrors.Should().BeEquivalentTo(new { ErrorMessage = "UpdateApprenticeshipStopDate is restricted to Employers only - Provider is invalid" });
}

[Test]
Expand All @@ -144,7 +144,7 @@ public async Task Handle_WhenHandlingCommand_WithInvalidApprenticeshipForStop_Pa
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "newStopDate", ErrorMessage = "Apprenticeship must be stopped in order to update stop date" });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "newStopDate", ErrorMessage = "Apprenticeship must be stopped in order to update stop date" });
}

[Test]
Expand All @@ -159,7 +159,7 @@ public async Task Handle_WhenHandlingCommand_WhenValidatingApprenticeship_WithSt
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "newStopDate", ErrorMessage = "Invalid Date of Change. Date cannot be in the future." });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "newStopDate", ErrorMessage = "Invalid Date of Change. Date cannot be in the future." });
}


Expand All @@ -174,7 +174,7 @@ public async Task Handle_WhenHandlingCommand_WhenValidatingApprenticeship_WithSt
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "newStopDate", ErrorMessage = "The stop month cannot be before the apprenticeship started" });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "newStopDate", ErrorMessage = "The stop month cannot be before the apprenticeship started" });
}

[Test]
Expand All @@ -191,7 +191,7 @@ public async Task Handle_WhenHandlingCommand_WithValidateEndDateOverlap_ThenShou
var exception = Assert.ThrowsAsync<DomainException>(async () => await _handler.Handle(command, new CancellationToken()));

// Assert
exception.DomainErrors.Should().ContainEquivalentOf(new { PropertyName = "newStopDate", ErrorMessage = $"The date overlaps with existing dates for the same apprentice" });
exception.DomainErrors.Should().BeEquivalentTo(new { PropertyName = "newStopDate", ErrorMessage = $"The date overlaps with existing dates for the same apprentice" });
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task Then_Maps_ValidateApprenticeshipForEditRequestToValidateAppren
result.ApprenticeshipValidationRequest.EmployerReference.Should().BeEquivalentTo(source.EmployerReference);
result.ApprenticeshipValidationRequest.StartDate.Should().Be(source.StartDate);
result.ApprenticeshipValidationRequest.EndDate.Should().Be(source.EndDate);
result.ApprenticeshipValidationRequest.DeliveryModel.Should().Be(source.DeliveryModel);
result.ApprenticeshipValidationRequest.DeliveryModel.Should().BeEquivalentTo(source.DeliveryModel);
result.ApprenticeshipValidationRequest.CourseCode.Should().BeEquivalentTo(source.TrainingCode);
result.ApprenticeshipValidationRequest.ProviderReference.Should().BeEquivalentTo(source.ProviderReference);
result.ApprenticeshipValidationRequest.Email.Should().Be(source.Email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,6 @@ public void TrainingProgrammeIsMappedCorrectly()
Assert.AreEqual(_trainingProgramme.EffectiveTo, rs.TrainingProgramme.EffectiveTo);
}
}

[Test]
public void PriorLearningIsMappedCorrectly()
{
foreach (var source in _source.BulkUploadDraftApprenticeships)
{
var result = _result.First(y => y.Uln == source.Uln);
Assert.AreEqual(source.RecognisePriorLearning, result.RecognisePriorLearning);
Assert.AreEqual(source.DurationReducedBy, result.DurationReducedBy);
Assert.AreEqual(source.PriceReducedBy, result.PriceReducedBy);
}
}
}

public class BulkUploadAddDraftApprenticeshipRequestSpecimenBuilder : ISpecimenBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="AutoFixture.NUnit3" Version="4.11.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="EfCore.TestSupport" Version="1.6.1" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.21" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ private async Task<List<Error>> Validate(BulkUploadAddDraftApprenticeshipRequest
domainErrors.AddRange(ValidateProviderRef(csvRecord));
domainErrors.AddRange(ValidateEPAOrgId(csvRecord));
domainErrors.AddRange(ValidateReservation(csvRecord, reservationValidationResults));
domainErrors.AddRange(ValidatePriorLearning(csvRecord));

return domainErrors;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,5 @@ public int? AgeOnStartDate
}

public string StandardUId { get ; set ; }
public bool? RecognisePriorLearning { get; set; }

public int? DurationReducedBy { get; set; }

public int? PriceReducedBy { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public async Task<List<DraftApprenticeshipDetails>> Map(BulkUploadAddDraftAppren
Reference = source.ProviderRef,
ReservationId = source.ReservationId,
DeliveryModel = Types.DeliveryModel.Regular,
RecognisePriorLearning = source.RecognisePriorLearning,
DurationReducedBy = source.DurationReducedBy,
PriceReducedBy = source.PriceReducedBy,

};
await MapTrainingProgramme(source, result);
draftApprenticeshipDetailsList.Add(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ public void Merge(DraftApprenticeshipDetails source, Party modifyingParty)
FlexibleEmployment.EmploymentEndDate = null;
}

RecognisePriorLearning = source.RecognisePriorLearning;
if(RecognisePriorLearning == true)
{
PriorLearning ??= new ApprenticeshipPriorLearning();
PriorLearning.DurationReducedBy = source.DurationReducedBy;
PriorLearning.PriceReducedBy = source.PriceReducedBy;
}

ClearPriorLearningWhenStartDateBeforeAug2022();
}

Expand Down