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."); }
public async void WebClientIndicatesIdleWithZeroHashrate() { var settings = new TrexWebClient.Settings() { StatusUrl = "http://localhost" }; var httpClient = HttpClientMock.GetClientWithSpecificResultPayload("{ 'hashrate' : 0 }"); var mockLogger = new Mock <ILogger <TrexWebClient> >(); var webClient = new TrexWebClient(mockLogger.Object, Options.Create(settings), httpClient); (await webClient.IsMiningAsync()).Should().Be(false, "the hashrate is zero"); }
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"); }