示例#1
0
        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);
        }
示例#2
0
        public async Task Should_Return_Movie_Given_Title_When_Api_Key_Is_Valid()
        {
            var          uri                = new Uri("http://www.omdbapi.com");
            const string apiKey             = "e8ee624b";
            const string expectedMovieTitle = "Batman";

            var sut = new OmDbMovieService(uri, apiKey, new MovieTranslator());

            var actualResult = await sut.GetMovieByTitleAsync(expectedMovieTitle);

            actualResult.Should()
            .BeOfType <Movie>()
            .Which.Info.Title
            .Should().Be(expectedMovieTitle);
        }