コード例 #1
0
        private void ShouldEnqueueLinkRequestAndReturnAccepted()
        {
            var          faker            = Faker();
            const string programRefNo     = "129";
            const string patientReference = "4";
            var          id            = faker.Random.Hash();
            var          transactionId = faker.Random.Hash();
            var          correlationId = Uuid.Generate().ToString();
            var          linkRequest   = new LinkReferenceRequest(
                transactionId,
                new PatientLinkReference(
                    id,
                    patientReference,
                    new[] { new CareContextEnquiry(programRefNo) }),
                faker.Random.Hash());

            discoveryRequestRepository.Setup(x => x.RequestExistsFor(linkRequest.TransactionId,
                                                                     id,
                                                                     linkRequest.Patient.ReferenceNumber))
            .ReturnsAsync(true);

            var linkedResult = linkController.LinkFor(correlationId, linkRequest);

            backgroundJobClient.Verify(client => client.Create(
                                           It.Is <Job>(job => job.Method.Name == "LinkPatient" && job.Args[0] == linkRequest),
                                           It.IsAny <EnqueuedState>()
                                           ));

            link.Verify();
            discoveryRequestRepository.Verify();
            linkedResult.StatusCode.Should().Be(StatusCodes.Status202Accepted);
        }