Skip to content
Merged
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 @@ -53,8 +53,20 @@ public async Task<BlockParticipantResult> BlockParticipant(BlockParticipantDto b
return new BlockParticipantResult(false, "Participant Already Blocked");
}

var pdsParticipant = await GetPDSParticipant(blockParticipantRequest.NhsNumber);

if (pdsParticipant == null )
{
return new BlockParticipantResult(false, "Participant details do not match a record in PDS");
}

var participantDemographic = await _participantDemographicDataService.GetSingleByFilter(x => x.NhsNumber == blockParticipantRequest.NhsNumber);

if (participantDemographic == null)
{
return new BlockParticipantResult(false, "Can not retrieve record from demographic");
}

if (!ValidateRecordsMatch(participantDemographic, blockParticipantRequest))
{
_logger.LogWarning("Participant didn't pass three point check and cannot be blocked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess()
DateOfBirth = "19231012"
});

var pdsDemoResponse = JsonSerializer.Serialize(
new PdsDemographic
{
NhsNumber = "6427635034",
FamilyName = "Jones",
DateOfBirth = "1923-10-12"
});

_mockHttpClient.Setup(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny<Dictionary<string, string>>()))
.ReturnsAsync(pdsDemoResponse);


_mockParticipantManagementClient.Setup(x => x.Update(It.IsAny<ParticipantManagement>()))
.ReturnsAsync(true);
_mockHttpClient.Setup(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny<Dictionary<string, string>>()))
Expand All @@ -94,13 +106,13 @@ public async Task BlockParticipant_ExistingParticipant_ReturnsSuccess()
StatusCode = HttpStatusCode.OK
});


//act
var result = await _sut.BlockParticipant(_request.Object);

//asset
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
_mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny<Dictionary<string, string>>()), Times.Once);
_mockHttpClient.Verify(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny<Dictionary<string, string>>()), Times.Once);
_mockParticipantManagementClient.Verify(x => x.Update(It.IsAny<ParticipantManagement>()), Times.Once);
_mockHttpClient.VerifyNoOtherCalls();
}
Expand Down Expand Up @@ -232,10 +244,11 @@ public async Task BlockParticipant_ExistingParticipantFailsThreePointCheck_Retur
//asset
Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
_mockHttpClient.Verify(x => x.SendPost("NemsUnsubscribeUrl", It.IsAny<Dictionary<string, string>>()), Times.Never);
_mockHttpClient.Verify(x => x.SendGet("RetrievePdsDemographicUrl", It.IsAny<Dictionary<string, string>>()), Times.Once);
_mockHttpClient.VerifyNoOtherCalls();
_mockParticipantManagementClient.Verify(x => x.GetSingleByFilter(It.IsAny<Expression<Func<ParticipantManagement, bool>>>()), Times.Once);
_mockParticipantManagementClient.VerifyNoOtherCalls();
_mockParticipantDemographicClient.Verify(x => x.GetSingleByFilter(It.IsAny<Expression<Func<ParticipantDemographic, bool>>>()), Times.Once);
_mockParticipantDemographicClient.Verify(x => x.GetSingleByFilter(It.IsAny<Expression<Func<ParticipantDemographic, bool>>>()), Times.Never);
_mockParticipantDemographicClient.VerifyNoOtherCalls();
}
[TestMethod]
Expand Down
Loading