Ejemplo n.º 1
0
        public void GetMovieById_ShouldThrowException()
        {
            var logicHandler = new LogicHandler();
            var testMovies   = GetTestMovies();
            var testId       = "dsak";

            Assert.ThrowsException <ArgumentNullException>(() => logicHandler.GetSingleMovie(testMovies, testId));
        }
Ejemplo n.º 2
0
        public void GetMovieById_ShouldSucceed()
        {
            var logicHandler = new LogicHandler();
            var testMovies   = GetTestMovies();
            var testId       = "tt0111161";

            var expected = testMovies.Where(i => i.Id == testId).First();
            var actual   = logicHandler.GetSingleMovie(testMovies, testId);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public IActionResult GetMovieById(string id)
        {
            Movie movieToReturn = null;
            var   movies        = MovieHttpClient.GetInstance().GetMovies();

            if (!movies.Any())
            {
                return(new NoContentResult());
            }
            try
            {
                movieToReturn = logicHandler.GetSingleMovie(movies, id);
            }
            catch (Exception ex)
            {
                if (ex is ArgumentNullException)
                {
                    return(new BadRequestObjectResult("No movie with that id"));
                }
            }
            return(new OkObjectResult(movieToReturn));
        }