Esempio n. 1
0
        public async Task GetMovieDetail_MockServer_CorrectData()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(TestAppData.CinemaMovieDetailFilePath, HttpStatusCode.OK).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var moviesReadFromFile = JsonConvert.DeserializeObject <MovieDetail>(File.ReadAllText(TestAppData.CinemaMovieDetailFilePath));

            var externalService = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var result          = await externalService.GetMovieDetailAsync(_baseUrlCinema, _getMovieDetailCinema, _movieId);

            Assert.AreEqual(moviesReadFromFile.ID, result.ID);
            Assert.AreEqual(moviesReadFromFile.Actors, result.Actors);
            Assert.AreEqual(moviesReadFromFile.Awards, result.Awards);
            Assert.AreEqual(moviesReadFromFile.Country, result.Country);
            Assert.AreEqual(moviesReadFromFile.Director, result.Director);
            Assert.AreEqual(moviesReadFromFile.Genre, result.Genre);
            Assert.AreEqual(moviesReadFromFile.Language, result.Language);
            Assert.AreEqual(moviesReadFromFile.Metascore, result.Metascore);
            Assert.AreEqual(moviesReadFromFile.Plot, result.Plot);
            Assert.AreEqual(moviesReadFromFile.Poster, result.Poster);
            Assert.AreEqual(moviesReadFromFile.Price, result.Price);
            Assert.AreEqual(moviesReadFromFile.Votes, result.Votes);
            Assert.AreEqual(moviesReadFromFile.Rating, result.Rating);
            Assert.AreEqual(moviesReadFromFile.Type, result.Type);
            Assert.AreEqual(moviesReadFromFile.Writer, result.Writer);
            Assert.AreEqual(moviesReadFromFile.Rating, result.Rating);
            Assert.AreEqual(moviesReadFromFile.Title, result.Title);
            Assert.AreEqual(moviesReadFromFile.Rated, result.Rated);
            Assert.AreEqual(moviesReadFromFile.Released, result.Released);
            Assert.AreEqual(moviesReadFromFile.Runtime, result.Runtime);
        }
Esempio n. 2
0
        public async Task GetMovieDetail_MockServer_ExceptionHandle()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(new HttpRequestException()).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var externalService    = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var result             = await externalService.GetMovieDetailAsync(_baseUrlCinema, _getMovieDetailCinema, _movieId);

            Assert.IsNull(result);
        }
Esempio n. 3
0
        public async Task GetMovieDetail_MockServer_HandleErrorStatus()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(TestAppData.CinemaMovieDetailFilePath, HttpStatusCode.BadRequest).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var externalService    = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var result             = await externalService.GetMovieDetailAsync(_baseUrlCinema, _getMovieDetailCinema, _movieId);

            Assert.IsNull(result);
        }