public List <Movie> PostCupMovies([FromBody] MoviesDto movies)
        {
            try
            {
                Cup cup = Cup.New();

                foreach (Movie movie in movies.Movies)
                {
                    cup.AddMovie(movie);
                }

                cup.CupResult();

                List <Movie> response = new List <Movie>();

                foreach (Movie movie in cup.FinalResult)
                {
                    response.Add(movie);
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public void OrdenationMoviesIsCorrect()
        {
            List <Movie> MoviesCup      = new List <Movie>();
            List <Movie> ReturnExpected = new List <Movie>();

            MoviesCup.Add(Movie.New("tt3606756", "Os Incríveis 2", 2018, 8.5));
            MoviesCup.Add(Movie.New("tt4881806", "Jurassic World: Reino Ameaçado", 2018, 6.7));
            MoviesCup.Add(Movie.New("tt5164214", "Oito Mulheres e um Segredo", 2018, 6.3));
            MoviesCup.Add(Movie.New("tt7784604", "Hereditário", 2018, 7.8));
            MoviesCup.Add(Movie.New("tt4154756", "Vingadores: Guerra Infinita", 2018, 8.8));
            MoviesCup.Add(Movie.New("tt5463162", "Deadpool 2", 2018, 8.1));
            MoviesCup.Add(Movie.New("tt3778644", "Han Solo: Uma História Star Wars", 2018, 7.2));
            MoviesCup.Add(Movie.New("tt3501632", "Thor: Ragnarok", 2017, 7.9));

            ReturnExpected.Add(Movie.New("tt5463162", "Deadpool 2", 2018, 8.1));
            ReturnExpected.Add(Movie.New("tt3778644", "Han Solo: Uma História Star Wars", 2018, 7.2));
            ReturnExpected.Add(Movie.New("tt7784604", "Hereditário", 2018, 7.8));
            ReturnExpected.Add(Movie.New("tt4881806", "Jurassic World: Reino Ameaçado", 2018, 6.7));
            ReturnExpected.Add(Movie.New("tt5164214", "Oito Mulheres e um Segredo", 2018, 6.3));
            ReturnExpected.Add(Movie.New("tt3606756", "Os Incríveis 2", 2018, 8.5));
            ReturnExpected.Add(Movie.New("tt3501632", "Thor: Ragnarok", 2017, 7.9));
            ReturnExpected.Add(Movie.New("tt4154756", "Vingadores: Guerra Infinita", 2018, 8.8));

            Cup CupMovies = Cup.New();

            foreach (Movie movie in MoviesCup)
            {
                CupMovies.AddMovie(movie);
            }


            CupMovies.CupResult();

            List <Movie> response = new List <Movie>();

            foreach (Movie movie in CupMovies.CupOrdination)
            {
                response.Add(movie);
            }

            CollectionAssert.AreEqual(ReturnExpected, response, new MovieListComparer(), "Copa ordenada incorretamente!");
        }