Пример #1
0
        public async void IsRunningAsyncWhenResultCodeSucceeds()
        {
            var mockLogger = new Mock <ILogger <TrexWebClient> >();
            var settings   = new TrexWebClient.Settings()
            {
                StatusUrl = "http://localhost"
            };
            var httpClient = HttpClientMock.GetResponseWithStatusCode(HttpStatusCode.OK);
            var webClient  = new TrexWebClient(mockLogger.Object, Options.Create(settings), httpClient);

            (await webClient.IsRunningAsync()).Should().Be(true, "Because the request was not found.");
        }
Пример #2
0
        public async void IsRunningAsyncWhenResultCodeFails()
        {
            var mockLogger = new Mock <ILogger <TrexWebClient> >();
            var settings   = new TrexWebClient.Settings()
            {
                StatusUrl = "http://localhost"
            };
            var socketException = new System.Net.Sockets.SocketException(0);
            var ex         = new HttpRequestException("test", socketException);
            var httpClient = HttpClientMock.GetResponseThatThrowsException(ex);
            var webClient  = new TrexWebClient(mockLogger.Object, Options.Create(settings), httpClient);

            (await webClient.IsRunningAsync()).Should().Be(false, "We should swallow the conenction refused exception");
        }