Пример #1
0
        public void ItShouldSearchForMoviesByTitle()
        {
            var searchTerm = "Robocop";
              int expectedCount = 1;
              var movieRepo = new Mock<MovieRepository>();
              var movie = new Movie {Title = searchTerm};
              movieRepo.Setup(it => it.SearchMovies(searchTerm)).Returns(new List<Movie> {movie});

              var movieCatalogue = new MovieCatalogue(movieRepo.Object);
              var result = movieCatalogue.SearchMovies(searchTerm).ToList();

              Assert.AreEqual(expectedCount, result.Count());
              Assert.AreEqual(searchTerm, result[0].Title);
        }
Пример #2
0
        public ViewResult SearchPage(SearchRequestViewModel searchRequestViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(new SearchResultViewModel {
                    PageTitle = "Please Try Again"
                }));
            }

            var searchTerm = searchRequestViewModel.SearchTerm;
            var movies     = _movieCatalogue.SearchMovies(searchTerm).ToList().Take(searchRequestViewModel.NumRows);
            var viewModel  = new SearchResultViewModel {
                PageTitle = "Search Results", Movies = movies
            };

            return(View(viewModel));
        }
Пример #3
0
        public void ItShouldSearchForMoviesByTitle()
        {
            var searchTerm    = "Robocop";
            int expectedCount = 1;
            var movieRepo     = new Mock <MovieRepository>();
            var movie         = new Movie {
                Title = searchTerm
            };

            movieRepo.Setup(it => it.SearchMovies(searchTerm)).Returns(new List <Movie> {
                movie
            });

            var movieCatalogue = new MovieCatalogue(movieRepo.Object);
            var result         = movieCatalogue.SearchMovies(searchTerm).ToList();

            Assert.AreEqual(expectedCount, result.Count());
            Assert.AreEqual(searchTerm, result[0].Title);
        }