Exemple #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 serviceStatusCUIApp = new ServiceStatusCUIApp(fakeApplicationLogger, fakeHttpClientService);
            var serviceStatus       = await serviceStatusCUIApp.GetCurrentCUIAppStatusAsync(A.Dummy <string>(), A.Dummy <string>());

            //Asserts
            serviceStatus.Status.Should().NotBe(ServiceState.Green);
            A.CallTo(() => fakeApplicationLogger.ErrorJustLogIt(A <string> ._, A <Exception> ._)).MustHaveHappened();
        }
Exemple #2
0
        public async Task GetServiceStatusAsync(HttpStatusCode returnHttpStatusCode, ServiceState expectedServiceStatus, string serviceStatusResponse)
        {
            //Arrange
            var responseJson = "[{\"service\": \"DFC.App.JobProfile\",\"message\": \"Document store" + serviceStatusResponse + "\"}]";

            var httpResponseMessage = new HttpResponseMessage
            {
                Content    = new StringContent(responseJson, Encoding.UTF8, "application/json"),
                StatusCode = returnHttpStatusCode
            };

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

            //Act
            var serviceStatusCUIApp = new ServiceStatusCUIApp(fakeApplicationLogger, fakeHttpClientService);
            var serviceStatus       = await serviceStatusCUIApp.GetCurrentCUIAppStatusAsync(A.Dummy <string>(), A.Dummy <string>());

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