Skip to content

Commit

Permalink
Create populated MQ by default in tests (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Jan 2, 2024
1 parent 68e0ae1 commit bf0ba2b
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class GetAllSpecialismsHandler : ICrmQueryHandler<GetAllSpecialismsQuery,
public async Task<dfeta_specialism[]> Execute(GetAllSpecialismsQuery query, IOrganizationServiceAsync organizationService)
{
var filter = new FilterExpression(LogicalOperator.And);
filter.AddCondition(dfeta_specialism.Fields.StateCode, ConditionOperator.Equal, (int)dfeta_specialismState.Active);
filter.AddCondition(dfeta_specialism.Fields.dfeta_Value, ConditionOperator.In, "Hearing", "Multi-Sensory", "Visual");

var queryExpression = new QueryExpression
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public async Task WhenCalled_ForContactWithoutQualifications_ReturnsEmptyArray()
public async Task WhenCalled_ForContactWithQualifications_ReturnsQualificationsAsExpected()
{
// Arrange
var person = await _dataScope.TestData.CreatePerson(
x => x.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification()
.WithMandatoryQualification(providerValue: "959", specialism: MandatoryQualificationSpecialism.Visual));
var person = await _dataScope.TestData.CreatePerson(x => x
.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification()
.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue("959").WithSpecialism(MandatoryQualificationSpecialism.Visual)));

// Act
var qualifications = await _crmQueryDispatcher.ExecuteQuery(new GetQualificationsByContactIdQuery(person.ContactId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public async Task QueryExecutesSuccessfully()
var originalMqEstablishmentValue = "955";
var newMqEstablishment = await _dataScope.TestData.ReferenceDataCache.GetMqEstablishmentByValue("959"); // University of Leeds

var person = await _dataScope.TestData.CreatePerson(
x => x.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(providerValue: originalMqEstablishmentValue));
var person = await _dataScope.TestData.CreatePerson(x => x
.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(originalMqEstablishmentValue)));

var qualification = person.MandatoryQualifications.First();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public async Task QueryExecutesSuccessfully()
var originalSpecialism = MandatoryQualificationSpecialism.Visual;
var newSpecialism = await _dataScope.TestData.ReferenceDataCache.GetMqSpecialismByValue(MandatoryQualificationSpecialism.Hearing.GetDqtValue());

var person = await _dataScope.TestData.CreatePerson(
x => x.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(specialism: originalSpecialism));
var person = await _dataScope.TestData.CreatePerson(x => x
.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(q => q.WithSpecialism(originalSpecialism)));

var qualification = person.MandatoryQualifications.First();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public async Task QueryExecutesSuccessfully()
var originalStartDate = new DateOnly(2021, 10, 5);
var newStartDate = new DateOnly(2020, 11, 7);

var person = await _dataScope.TestData.CreatePerson(
x => x.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(startDate: originalStartDate));
var person = await _dataScope.TestData.CreatePerson(x => x
.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(q => q.WithStartDate(originalStartDate)));

var qualification = person.MandatoryQualifications.First();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public async Task QueryExecutesSuccessfully(
DateOnly? originalEndDate = !string.IsNullOrEmpty(originalEndDateString) ? DateOnly.Parse(originalEndDateString) : null;
DateOnly? newEndDate = !string.IsNullOrEmpty(newEndDateString) ? DateOnly.Parse(newEndDateString) : null;

var person = await _dataScope.TestData.CreatePerson(
x => x.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(status: originalMqStatus, endDate: originalEndDate));
var person = await _dataScope.TestData.CreatePerson(x => x
.WithQts(qtsDate: new DateOnly(2021, 10, 5))
.WithMandatoryQualification(q => q.WithStatus(originalMqStatus).WithEndDate(originalEndDate)));

var qualification = person.MandatoryQualifications.First();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public async Task EditMqStartDate()
{
var oldStartDate = new DateOnly(2021, 10, 5);
var newStartDate = new DateOnly(2021, 10, 6);
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(startDate: oldStartDate));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithStartDate(oldStartDate)));
var personId = person.PersonId;
var qualificationId = person.MandatoryQualifications.Single().QualificationId;

Expand Down Expand Up @@ -177,7 +177,7 @@ public async Task EditMqResult()
var oldStatus = MandatoryQualificationStatus.Failed;
var newStatus = MandatoryQualificationStatus.Passed;
var newEndDate = new DateOnly(2021, 11, 5);
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(status: oldStatus));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithStatus(oldStatus)));
var personId = person.PersonId;
var qualificationId = person.MandatoryQualifications.Single().QualificationId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ public async Task Get_ValidRequest_DisplaysContentAsExpected(
DateOnly? startDate = !string.IsNullOrEmpty(startDateString) ? DateOnly.Parse(startDateString) : null;
DateOnly? endDate = !string.IsNullOrEmpty(endDateString) ? DateOnly.Parse(endDateString) : null;

var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(
providerValue: providerValue,
specialism: specialism,
startDate: startDate,
endDate: endDate,
status: status));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q
.WithDqtMqEstablishmentValue(providerValue)
.WithSpecialism(specialism)
.WithStartDate(startDate)
.WithEndDate(endDate)
.WithStatus(status)));
var qualification = person.MandatoryQualifications.Single();
var journeyInstance = await CreateJourneyInstance(
qualification.QualificationId,
Expand Down Expand Up @@ -157,12 +156,12 @@ public async Task Post_Confirm_DeletesMqCreatesEventCompletesJourneyAndRedirects
var evidenceFileId = Guid.NewGuid();
var evidenceFileName = "test.pdf";

var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(
providerValue: mqEstablishmentDqtValue,
specialism: specialism,
status: status,
startDate: startDate,
endDate: endDate));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q
.WithDqtMqEstablishmentValue(mqEstablishmentDqtValue)
.WithSpecialism(specialism)
.WithStatus(status)
.WithStartDate(startDate)
.WithEndDate(endDate)));

var qualificationId = person.MandatoryQualifications!.Single().QualificationId;
var mqEstablishment = await TestData.ReferenceDataCache.GetMqEstablishmentByValue(mqEstablishmentDqtValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public async Task Get_ValidRequest_DisplaysContentAsExpected()
var oldMqEstablishment = await TestData.ReferenceDataCache.GetMqEstablishmentByValue(oldMqEstablishmentValue);
var newMqEstablishmentValue = "959"; // University of Leeds
var newMqEstablishment = await TestData.ReferenceDataCache.GetMqEstablishmentByValue(newMqEstablishmentValue);
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: oldMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(oldMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -107,8 +106,7 @@ public async Task Post_Confirm_CompletesJourneyAndRedirectsWithFlashMessage()
// Arrange
var oldMqEstablishmentValue = "955"; // University of Birmingham
var newMqEstablishmentValue = "959"; // University of Leeds
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: oldMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(oldMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -145,8 +143,7 @@ public async Task Post_Cancel_DeletesJourneyAndRedirects()
// Arrange
var oldMqEstablishmentValue = "955"; // University of Birmingham
var newMqEstablishmentValue = "959"; // University of Leeds
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: oldMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(oldMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public async Task Get_ValidRequestWithUninitializedJourneyState_PopulatesModelFr
{
// Arrange
var databaseMqEstablishmentValue = "955"; // University of Birmingham
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: databaseMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(databaseMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(qualificationId);

Expand All @@ -58,8 +57,7 @@ public async Task Get_ValidRequestWithInitializedJourneyState_PopulatesModelFrom
// Arrange
var databaseMqEstablishmentValue = "955"; // University of Birmingham
var journeyMqEstablishmentValue = "959"; // University of Leeds
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: databaseMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(databaseMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -135,8 +133,7 @@ public async Task Post_WhenProviderIsSelected_RedirectsToConfirmPage()
// Arrange
var oldMqEstablishmentValue = "955"; // University of Birmingham
var newMqEstablishmentValue = "959"; // University of Leeds
var person = await TestData.CreatePerson(
b => b.WithMandatoryQualification(providerValue: oldMqEstablishmentValue));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithDqtMqEstablishmentValue(oldMqEstablishmentValue)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task Get_ValidRequest_DisplaysContentAsExpected()
// Arrange
var oldMqSpecialism = MandatoryQualificationSpecialism.Hearing;
var newMqSpecialism = MandatoryQualificationSpecialism.Visual;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: oldMqSpecialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(oldMqSpecialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task Post_Confirm_CompletesJourneyAndRedirectsWithFlashMessage()
// Arrange
var oldMqSpecialism = MandatoryQualificationSpecialism.Hearing;
var newMqSpecialism = MandatoryQualificationSpecialism.Visual;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: oldMqSpecialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(oldMqSpecialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -140,7 +140,7 @@ public async Task Post_Cancel_DeletesJourneyAndRedirects()
{
// Arrange
var specialism = MandatoryQualificationSpecialism.Hearing;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: specialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(specialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task Get_ValidRequestWithUninitializedJourneyState_PopulatesModelFr
{
// Arrange
var databaseSpecialism = MandatoryQualificationSpecialism.Hearing;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: databaseSpecialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(databaseSpecialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(qualificationId);

Expand All @@ -58,7 +58,7 @@ public async Task Get_ValidRequestWithInitializedJourneyState_PopulatesModelFrom
// Arrange
var databaseSpecialism = MandatoryQualificationSpecialism.Hearing;
var journeySpecialism = MandatoryQualificationSpecialism.Visual;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: databaseSpecialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(databaseSpecialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -135,7 +135,7 @@ public async Task Post_WhenSpecialismIsSelected_RedirectsToConfirmPage()
// Arrange
var oldSpecialism = MandatoryQualificationSpecialism.Hearing;
var newSpecialism = MandatoryQualificationSpecialism.Visual;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: oldSpecialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(oldSpecialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -168,7 +168,7 @@ public async Task Post_Cancel_DeletesJourneyAndRedirects()
{
// Arrange
var specialism = MandatoryQualificationSpecialism.Hearing;
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(specialism: specialism));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithSpecialism(specialism)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task Get_ValidRequest_DisplaysContentAsExpected()
// Arrange
var oldStartDate = new DateOnly(2021, 10, 5);
var newStartDate = new DateOnly(2021, 10, 6);
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(startDate: oldStartDate));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithStartDate(oldStartDate)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task Post_Confirm_CompletesJourneyAndRedirectsWithFlashMessage()
// Arrange
var oldStartDate = new DateOnly(2021, 10, 5);
var newStartDate = new DateOnly(2021, 10, 6);
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(startDate: oldStartDate));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithStartDate(oldStartDate)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down Expand Up @@ -141,7 +141,7 @@ public async Task Post_Cancel_DeletesJourneyAndRedirects()
{
// Arrange
var oldStartDate = new DateOnly(2021, 10, 5);
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(startDate: oldStartDate));
var person = await TestData.CreatePerson(b => b.WithMandatoryQualification(q => q.WithStartDate(oldStartDate)));
var qualificationId = person.MandatoryQualifications!.First().QualificationId;
var journeyInstance = await CreateJourneyInstance(
qualificationId,
Expand Down
Loading

0 comments on commit bf0ba2b

Please sign in to comment.