Skip to content

HttpRequestMessage for HttpClient methods #137

Answered by diegodrf
Raphsodyz asked this question in Q&A
Discussion options

You must be logged in to vote

I think the error is in your code.

You are trying to read the property LaunchView.Exception in Assert.IsType<AggregateException>(result.Exception); but you are not saving the value of the exception in this property and returning it gracefully.

When the status code is not 200 you throw an exception and not catching it.

if (!response.IsSuccessStatusCode)
                    throw new HttpRequestException($"{response.StatusCode} - {ErrorMessages.LaunchApiEndPointError}");

The correct way to test it is by calling Assert.ThrowsAsync if you are using XUnit or equivalent in another package.

Pay attention to await too. You are using an async method and not awaiting. So at line var result = busine…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Raphsodyz
Comment options

@diegodrf
Comment options

Answer selected by Raphsodyz
@Raphsodyz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants