Пример #1
0
        public async System.Threading.Tasks.Task LoadPatientAsync_ShouldReturnError_WhenFound()
        {
            //Given
            var openmrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClientMock.Object);
            var invalidPatientId    = "000000000";
            var path = $"{Endpoints.Fhir.OnPatientPath}/{invalidPatientId}";

            openmrsClientMock
            .Setup(x => x.GetAsync(path))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.NotFound,
                Content    = new StringContent(PatientNotFoundData)
            })
            .Verifiable();

            //When
            var patient = await discoveryDataSource.LoadPatientAsync(invalidPatientId);

            //Then
            patient.Name.Should().BeEmpty();
            patient.Gender.Should().Be(null);
        }
Пример #2
0
        public async System.Threading.Tasks.Task LoadPatientAsync_ShouldReturnPatient_WhenFound()
        {
            //Given
            var openmrsClientMock   = new Mock <IOpenMrsClient>();
            var discoveryDataSource = new FhirDiscoveryDataSource(openmrsClientMock.Object);
            var patientId           = "95db77c6-cc8a-4208-99cc-c69a207114a3";
            var path = $"{Endpoints.Fhir.OnPatientPath}/{patientId}";

            openmrsClientMock
            .Setup(x => x.GetAsync(path))
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(SamplePatient)
            })
            .Verifiable();

            //When
            var patient = await discoveryDataSource.LoadPatientAsync(patientId);

            //Then
            Assert.NotNull(patient);
            patient.Name[0].GivenElement.First().ToString().Should().Be("test");
        }