public async Task GetConditionsAsync_ThrowsExceptionWhenTapioReturnsErrorCode() { var messageHandlerMock = new Mock <HttpMessageHandler>() .SetupSendAsyncMethod(HttpStatusCode.Unauthorized, "{}"); const string testMachineId = "TestMachineId"; using (var httpClient = new HttpClient(messageHandlerMock.Object)) { var service = new HistoricConditionsService(httpClient, _standardTokenProviderMock.Object); Func <Task <HistoricConditionsResponse> > action = () => service.GetConditionsAsync(CancellationToken.None, testMachineId); await action.Should().ThrowAsync <HttpRequestException>(); } }
public async Task ReadConditionsAsync_ThrowNoException() { var messageHandlerMock = new Mock <HttpMessageHandler>() .SetupSendAsyncMethod(HttpStatusCode.OK, "{}"); const string testMachineId = "TestMachineId"; using (var httpClient = new HttpClient(messageHandlerMock.Object)) { var service = new HistoricConditionsService(httpClient, _standardTokenProviderMock.Object); Func <Task <HistoricConditionsResponse> > action = () => service.ReadConditionsAsync(CancellationToken.None, testMachineId); await action.Should().NotThrowAsync(); } }