示例#1
0
        public async void GivenValidFhirClientConfig_WhenCheckHealthAsync_ThenRespondWithSuccess_Test()
        {
            var fhirClient = Substitute.For <IFhirClient>();
            var service    = new R4FhirHealthService(fhirClient);
            var response   = await service.CheckHealth();

            Assert.Equal(200, response.StatusCode);
            Assert.Equal(string.Empty, response.Message);
        }
示例#2
0
        public async void GivenInvalidUrl_WhenCheckHealthAsync_ThenRespondWithGenericException_Test()
        {
            var fhirClient = Utilities.CreateMockFhirService();

            fhirClient.SearchForResourceAsync(Arg.Any <ResourceType>(), Arg.Any <string>(), Arg.Any <int>(), default).ThrowsForAnyArgs(new Exception("No such host is known"));

            var service  = new R4FhirHealthService(fhirClient);
            var response = await service.CheckHealth();

            Assert.Equal(500, response.StatusCode);
            Assert.Equal("No such host is known", response.Message);
        }
示例#3
0
        public async void GivenInvalidOAuthToken_WhenCheckHealthAsync_ThenRespondWithFhirOperationException_Test()
        {
            var fhirClient = Utilities.CreateMockFhirService();

            fhirClient.SearchForResourceAsync(Arg.Any <ResourceType>(), Arg.Any <string>(), Arg.Any <int>(), default).ThrowsForAnyArgs(new FhirException(new FhirResponse <OperationOutcome>(new HttpResponseMessage(HttpStatusCode.Unauthorized), new OperationOutcome())));

            var service  = new R4FhirHealthService(fhirClient);
            var response = await service.CheckHealth();

            Assert.Equal(401, response.StatusCode);
            Assert.Equal("Unauthorized: ", response.Message);
        }
示例#4
0
        public async void GivenValidFhirClientConfig_WhenCheckHealthAsync_ThenRespondWithSuccess_Test()
        {
            var fhirClient = Utilities.CreateMockFhirService();

            fhirClient.SearchForResourceAsync(Arg.Any <ResourceType>(), Arg.Any <string>(), Arg.Any <int>(), default).ReturnsForAnyArgs(new FhirResponse <Bundle>(new HttpResponseMessage(HttpStatusCode.OK), null));

            var service  = new R4FhirHealthService(fhirClient);
            var response = await service.CheckHealth();

            Assert.Equal(200, response.StatusCode);
            Assert.Equal(string.Empty, response.Message);
        }
示例#5
0
        public async void GivenInvalidClientSecret_WhenCheckHealthAsync_ThenRespondWithAADException_Test()
        {
            var fhirClient = Utilities.CreateMockFhirService();

            fhirClient.SearchForResourceAsync(Arg.Any <ResourceType>(), Arg.Any <string>(), Arg.Any <int>(), default).ThrowsForAnyArgs(new IdentityModel.Clients.ActiveDirectory.AdalServiceException("AADSTS123", "Unauthorized")
            {
                StatusCode = 401
            });

            var service  = new R4FhirHealthService(fhirClient);
            var response = await service.CheckHealth();

            Assert.Equal(401, response.StatusCode);
            Assert.Equal("Unauthorized", response.Message);
        }