diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Core/Operations/SetQTLS.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Core/Operations/SetQTLS.cs index 2ec81063a..bc28ea8e0 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Core/Operations/SetQTLS.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Core/Operations/SetQTLS.cs @@ -32,7 +32,7 @@ public class SetQTLSHandler(ICrmQueryDispatcher _crmQueryDispatcher) } var (induction, hasABInduction) = await GetInductionWithAppropriateBody(contact.Id); - if (!CanSetQTLSDate(contact.dfeta_QTSDate.HasValue, contact.dfeta_InductionStatus, induction?.dfeta_InductionStatus, hasABInduction, contact.dfeta_qtlsdate, command.QTSDate)) + if (!CanSetQTLSDate(hasQTS: contact.dfeta_QTSDate.HasValue, overallInductionStatus: contact.dfeta_InductionStatus, inductionStatus: induction?.dfeta_InductionStatus, hasInductionWithAB: hasABInduction, existingQtlsdate: contact.dfeta_qtlsdate, incomingQtlsDate: command.QTSDate)) { var _ = await _crmQueryDispatcher.ExecuteQuery( new CreateReviewTaskQuery() diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/V3/V20240307/SetQTLSDateRequestTests.cs b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/V3/V20240307/SetQTLSDateRequestTests.cs index fa91e8c49..2ee6583a5 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/V3/V20240307/SetQTLSDateRequestTests.cs +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/V3/V20240307/SetQTLSDateRequestTests.cs @@ -176,7 +176,7 @@ public async Task Put_ValidQTSDateWithNoExistingQTSDate_ReturnsExpectedResult() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert await AssertEx.JsonResponseEquals( @@ -368,7 +368,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsInProgress_ReturnsStatusAccept // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Equal(expectedInductionStatus, contact!.dfeta_InductionStatus); @@ -417,7 +417,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsNotYetCompleted_SetsInductionS // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -463,7 +463,7 @@ public async Task Put_ClearQTLSWhenInductionStatusIsNotYetCompleted_SetsInductio // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -508,7 +508,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsInductionExtendedWithoutAB_Set // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -554,7 +554,7 @@ public async Task Put_ClearQTLSWhenInductionStatusIsInductionExtendedWithAB_Sets // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -598,7 +598,7 @@ public async Task Put_ClearQTLSWhenInductionStatusIsInductionExtendedWithAB_Sets // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.NotNull(task); @@ -641,7 +641,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsExempt_SetsInductionStatusExem // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -688,7 +688,7 @@ public async Task Put_ClearQTLSWhenInductionStatusIsExempt_SetsInductionStatusEx // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -733,7 +733,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsPass_SetsInductionStatusPass() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -780,7 +780,7 @@ public async Task Put_ClearQTLSWhenInductionStatusPass_SetsInductionStatusPass() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -825,7 +825,7 @@ public async Task Put_SetQTLSWhenInductionStatusFail_ReturnsAccepted() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.NotNull(task); @@ -876,7 +876,7 @@ public async Task Put_ClearQTLSWhenInductionStatusFail_ReturnsAccepted() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.NotNull(task); @@ -925,7 +925,7 @@ public async Task Put_SetQTLSWhenInductionStatusIsPassedInWales_SetsInductionSta // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -972,7 +972,7 @@ public async Task Put_ClearQTLSWhenInductionStatusPassedInWales_SetsInductionSta // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.Null(task); @@ -1017,7 +1017,7 @@ public async Task Put_SetQTLSWhenInductionStatusFailedInWales_ReturnsAccepted() // Act var response = await GetHttpClientWithApiKey().SendAsync(request); var contact = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.ContactId == existingContact.PersonId); - var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId == existingContact.ContactId.ToEntityReference(Contact.EntityLogicalName) && x.Subject == "Notification for SET QTLS data collections team"); + var task = XrmFakedContext.CreateQuery().FirstOrDefault(x => x.RegardingObjectId.Id == existingContact.PersonId && x.Subject == "Notification for SET QTLS data collections team"); // Assert Assert.NotNull(task);