public async void ReturnTrue() { var sut = new ExternalSimCardsProviderService(options, httpClient); var actual = await sut.PostOrder(expectedOrder); actual.Should().BeTrue(); }
public async void CallExternalService() { var sut = new ExternalSimCardsProviderService(options, httpClient); await sut.PostOrder(expectedOrder); handlerMock.VerifyAll(); }
public async void ReturnFalseWhenResponseStatusCodeIsNotOK() { var handlerWithErrorMock = new Mock <DelegatingHandler>(); handlerWithErrorMock.Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.Is <HttpRequestMessage>( x => x.RequestUri == expectedUrl), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(JsonSerializer.Serialize(expectedOrder)) } )); var httpClientWithError = new HttpClient(handlerWithErrorMock.Object); var sut = new ExternalSimCardsProviderService(options, httpClientWithError); var actual = await sut.PostOrder(expectedOrder); actual.Should().BeFalse(); }