public async Task Should_Call_Api_Given_Movie_Title_And_Api_Key() { var expectedResponse = new Fixture().Create <OmDbMovieResponse>(); var movieTranslator = new MovieTranslator(); var expectedMovie = movieTranslator.Translate(expectedResponse); using var httpTest = new HttpTest(); httpTest.RespondWithJson(expectedResponse); var sut = new OmDbMovieService(new Uri("http://fake-url.com/"), "fake-api-key", movieTranslator); var actualResult = await sut.GetMovieByTitleAsync("movie-title"); actualResult .Should() .NotBeNull() .And .BeOfType <Movie>() .Which.Should().BeEquivalentTo(expectedMovie); httpTest .ShouldHaveCalled("http://fake-url.com/*") .WithVerb(HttpMethod.Get) .WithQueryParams(new { t = "movie-title", apikey = "fake-api-key" }) .Times(Once); }
public void Should_Not_Translate_When_OmDb_Movie_Response_Is_Null() { _sut = new MovieTranslator(); var actualResult = _sut.Translate(null); actualResult.Should() .BeOfType <Movie>() .Which.Should() .Be(Movie.Empty); }
public MovieTranslatorTests() { _sut = new MovieTranslator(); }