Exemplo n.º 1
0
        public async Task GetServiceStatusExceptionAsync()
        {
            //Arrange
            //add no content to cause an exception
            var httpResponseMessage = new HttpResponseMessage();

            A.CallTo(() => fakeHttpClientService.PostAsync(A <string> ._, A <string> ._, A <FaultToleranceType> ._)).Throws(new HttpRequestException());

            //Act
            var shellHealthCheck = new CUIShellHealthCheck(fakeApplicationLogger, fakeConfigurationProvider, fakeHttpClientService);
            var serviceStatus    = await shellHealthCheck.GetCurrentStatusAsync();

            //Asserts
            serviceStatus.Status.Should().NotBe(ServiceState.Green);
            A.CallTo(() => fakeApplicationLogger.ErrorJustLogIt(A <string> ._, A <Exception> ._)).MustHaveHappened();
        }
Exemplo n.º 2
0
        public async Task GetServiceStatusAsync(HttpStatusCode returnHttpStatusCode, ServiceState expectedServiceStatus)
        {
            //Arrange
            var httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = returnHttpStatusCode
            };

            A.CallTo(() => fakeConfigurationProvider.GetConfig <string>(A <string> ._)).Returns(A.Dummy <string>());
            A.CallTo(() => fakeHttpClientService.GetAsync(A <string> ._, A <FaultToleranceType> ._)).Returns(httpResponseMessage);

            //Act
            var shellHealthCheck = new CUIShellHealthCheck(fakeApplicationLogger, fakeConfigurationProvider, fakeHttpClientService);
            var serviceStatus    = await shellHealthCheck.GetCurrentStatusAsync();

            //Assert
            serviceStatus.Status.Should().Be(expectedServiceStatus);
        }