Esempio n. 1
0
        public async Task GetAllMovies_MockServer_HandleErrorStatus()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(TestAppData.CinemaWorldAllMoviesFilePath, HttpStatusCode.BadRequest).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var externalService    = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var result             = await externalService.GetAllMoviesAsync(_baseUrlCinema, _getMovieCinema);

            Assert.IsNull(result);
        }
Esempio n. 2
0
        public async Task GetAllMovies_MockServer_CorrectCount()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(TestAppData.CinemaWorldAllMoviesFilePath, HttpStatusCode.OK).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var externalService    = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var result             = await externalService.GetAllMoviesAsync(_baseUrlCinema, _getMovieCinema);

            Assert.AreEqual(7, result.MovieCollection.Count);
        }
Esempio n. 3
0
        public async Task GetAllMovie_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.GetAllMoviesAsync(_baseUrlCinema, _getMovieDetailCinema);

            Assert.IsNull(result);
        }
Esempio n. 4
0
        public async Task GetAllMovies_MockServer_CorrectData()
        {
            var httpMessageHandler = _movieHelperService.GetMockHttpMessageHandler(TestAppData.CinemaWorldAllMoviesFilePath, HttpStatusCode.OK).Object;
            var apiHelper          = _movieHelperService.GetMockApiHelperService(httpMessageHandler, _baseUrlCinema).Object;
            var moviesReadFromFile = _movieHelperService.ReadAllMoviesFromFile(Providers.CinemaWorld);

            var moviesFromExternalSystem = new ExternalMovieService(_apiUtilityService.Object, apiHelper);
            var moviesFromApiCall        = await moviesFromExternalSystem.GetAllMoviesAsync(_baseUrlCinema, _getMovieCinema);

            foreach (var movie in moviesReadFromFile.MovieCollection)
            {
                foreach (var resultMove in moviesFromApiCall.MovieCollection.Where(resultMove => movie.ID == resultMove.ID))
                {
                    Assert.AreEqual(movie.Poster, resultMove.Poster);
                    Assert.AreEqual(movie.Title, resultMove.Title);
                    Assert.AreEqual(movie.Type, resultMove.Type);
                    Assert.AreEqual(movie.Year, resultMove.Year);
                }
            }
        }