public IActionResult GetMovies([FromQuery] bool ascending) { var movies = MovieHttpClient.GetInstance().GetMovies(); var sortedMovies = logicHandler.SortMovies(movies, ascending); if (sortedMovies.Any()) { return(new OkObjectResult(sortedMovies.Select(i => i.Title))); } else { return(new NoContentResult()); } }
public void SortMovies_ShouldSortDescending() { var logicHandler = new LogicHandler(); var testMovies = GetTestMovies(); var expected = GetTestMoviesOrderedDescending(); var actual = logicHandler.SortMovies(testMovies, false); for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i].Id, actual[i].Id); Assert.AreEqual(expected[i].Title, actual[i].Title); Assert.AreEqual(expected[i].Rated, actual[i].Rated); } }