private void ShouldEnqueueLinkConfirmationRequestAndReturnAccepted() { var linkReferenceNumber = Faker().Random.Hash(); const string token = "1234"; var cmId = "ncg"; var careContext = new[] { new CareContextRepresentation("129", Faker().Random.Word()) }; var expectedResponse = new PatientLinkConfirmationRepresentation(new LinkConfirmationRepresentation("4", Faker().Random.Word() , careContext)); var correlationId = Uuid.Generate().ToString(); link.Setup(e => e.VerifyAndLinkCareContext(It.Is <LinkConfirmationRequest>(p => p.Token == "1234" && p.LinkReferenceNumber == linkReferenceNumber))) .ReturnsAsync((expectedResponse, cmId, null)); var linkPatientRequest = new LinkPatientRequest(Faker().Random.Hash(), It.IsAny <string>(), new LinkConfirmation(linkReferenceNumber, token)); var response = linkController.LinkPatientFor(correlationId, linkPatientRequest); backgroundJobClient.Verify(client => client.Create( It.Is <Job>(job => job.Method.Name == "LinkPatientCareContextFor" && job.Args[0] == linkPatientRequest), It.IsAny <EnqueuedState>())); link.Verify(); discoveryRequestRepository.Verify(); response.StatusCode.Should().Be(StatusCodes.Status202Accepted); }