Beispiel #1
0
        public void ShouldGetMedications()
        {
            // Setup
            string hdid = "123912390123012";
            string phn  = "91985198";

            // Setup Patient result
            RequestResult <PatientModel> patientResult = new RequestResult <PatientModel>()
            {
                ResourcePayload = new PatientModel()
                {
                    PersonalHealthNumber = phn
                },
                ResultStatus = Common.Constants.ResultType.Success,
            };
            Mock <IPatientService> mockPatientService = CreatePatientService(hdid, patientResult);

            RequestResult <IList <MedicationRequest> > expectedDelegateResult = new RequestResult <IList <MedicationRequest> >()
            {
                ResultStatus    = ResultType.Success,
                ResourcePayload = new List <MedicationRequest>()
                {
                    new MedicationRequest()
                    {
                        ReferenceNumber = "abc"
                    },
                    new MedicationRequest()
                    {
                        ReferenceNumber = "xyz"
                    },
                },
                TotalResultCount = 2,
            };

            Mock <IMedicationRequestDelegate> mockDelegate = new Mock <IMedicationRequestDelegate>();

            mockDelegate
            .Setup(s => s.GetMedicationRequestsAsync(phn))
            .ReturnsAsync(expectedDelegateResult);

            IMedicationRequestService service = new MedicationRequestService(
                CreateLogger(),
                mockPatientService.Object,
                mockDelegate.Object);

            // Test
            RequestResult <IList <MedicationRequest> > response = Task.Run(async() =>
                                                                           await service.GetMedicationRequests(hdid)).Result;

            // Verify
            Assert.Equal(ResultType.Success, response.ResultStatus);
            Assert.Equal(2, response.TotalResultCount);
            Assert.Equal(2, response.ResourcePayload.Count);
        }
Beispiel #2
0
        public void ShouldErrorIfNoPatient()
        {
            // Setup
            string hdid = "123912390123012";

            // Setup Patient result
            RequestResult <PatientModel> patientResult = new RequestResult <PatientModel>()
            {
                ResultStatus = Common.Constants.ResultType.Error,
            };
            Mock <IPatientService> mockPatientService = CreatePatientService(hdid, patientResult);

            IMedicationRequestService service = new MedicationRequestService(
                CreateLogger(),
                mockPatientService.Object,
                new Mock <IMedicationRequestDelegate>().Object);

            // Test
            RequestResult <IList <MedicationRequest> > response = Task.Run(async() =>
                                                                           await service.GetMedicationRequests(hdid)).Result;

            // Verify
            Assert.Equal(ResultType.Error, response.ResultStatus);
        }