public async Task given_success_response_then_FindMovie_returns_response_content_correctly( HttpMessageHandlerDouble handlerStub, Uri endpoint, MovieDto content) { // Arrange Guid movieId = content.Id; bool predicate(HttpRequestMessage request) { string path = $"api/queries/Movies/{movieId}"; return(request.Method == HttpMethod.Get && request.RequestUri == new Uri(endpoint, path) && request.Content == default); } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = CreateContent(content), }; handlerStub.AddAnswer(predicate, answer: response); var sut = new ApiClient(new HttpClient(handlerStub), endpoint); // Act MovieDto actual = await sut.FindMovie(movieId); // Assert actual.Should().BeEquivalentTo(content); }
public async Task given_not_found_response_then_FindMovie_returns_null( HttpMessageHandlerDouble handlerStub, Uri endpoint, Guid movieId) { // Arrange bool predicate(HttpRequestMessage request) { string path = $"api/queries/Movies/{movieId}"; return(request.Method == HttpMethod.Get && request.RequestUri == new Uri(endpoint, path) && request.Content == default); } handlerStub.AddAnswer(predicate, HttpStatusCode.NotFound); var sut = new ApiClient(new HttpClient(handlerStub), endpoint); // Act MovieDto actual = await sut.FindMovie(movieId); // Assert actual.Should().BeNull(); }