Пример #1
0
        public void MovieNameTest()
        {
            IEnumerable<Movie> movie;
            var mockMovieRepository = MovieRepository(out movie);

            mockMovieRepository.Setup(obj => obj.GetMovies()).Returns(movie);

            IMovieService movieService = new MovieManager(mockMovieRepository.Object);

            IEnumerable<MovieData> data = movieService.GetDirectorNames();

            data.Should().HaveCount(4, "because we put these many values only");
        }
Пример #2
0
        public void MovieTest()
        {
            IEnumerable<Movie> movie;
            var mockMovieRepository = MovieRepository(out movie);

            //so, now i am going to setup the mock, Hence below i am telling that when you are encountering
            //following member of mockMovieRepository that receives the following information of GetMovies
            //obj is the implementation of mockMovieRepository. see, mock is creating the test class behind
            //the scene.
            mockMovieRepository.Setup(obj => obj.GetMovies()).Returns(movie);

            IMovieService movieService = new MovieManager(mockMovieRepository.Object);

            IEnumerable<MovieData> data = movieService.GetDirectorNames();

            Assert.AreEqual(2,data.Count());
               // Assert.IsTrue(data.GetEnumerator().Current.DirectorName);

            //Assert.IsTrue(data.ElementAt(0)("James Cameron"));
        }