public async Task GetProductByIdAsync_ShouldThrowArgumentException_WhenProductIdIsInValid() { //Arrange var sut = new ProductRest(_httpClientFactoryWrapper, _configuration, _loggerFactory); //Act Task <WishListProduct> func() => sut.GetProductByIdAsync(string.Empty); //Assert await Assert.ThrowsAsync <ArgumentException>(func); }
public async Task GetProductByIdAsync_ShouldReturnProduct_WhenExternalServiceResponseIsValid() { HttpResponseMessage response = GetSuccessMockResponse(); _httpClientFactoryWrapper.SendAsync(Arg.Any <HttpRequestMessage>(), "product").Returns(response); //Act var sut = new ProductRest(_httpClientFactoryWrapper, _configuration, _loggerFactory); var product = await sut.GetProductByIdAsync(_productId); //Assert Assert.NotNull(product); }
public async Task GetProductByIdAsync_ShouldThrowHttpRequestException_WhenTimeoutIsReached() { //Arrange var sut = new ProductRest(_httpClientFactoryWrapper, _configuration, _loggerFactory); _httpClientFactoryWrapper .When(x => x.SendAsync(Arg.Any <HttpRequestMessage>(), "product")) .Do((callinfo) => throw new TimeoutRejectedException()); //Act Task <WishListProduct> func() => sut.GetProductByIdAsync(_productId); //Assert await Assert.ThrowsAsync <HttpRequestException>(func); }