Beispiel #1
0
        public async Task ShouldProviderMergeOverlappingMovies()
        {
            List <MovieDetails> cinemaWorldMovies = new List <MovieDetails>();

            cinemaWorldMovies.Add(new MovieDetails {
                ID = "cw123", Title = "HOBBIT 1", Price = 75
            });
            cinemaWorldMovies.Add(new MovieDetails {
                ID = "cw955", Title = "HOBBIT 2", Price = 96
            });

            mockCinemaWorldService = new Mock <ICinemaWorldService>(MockBehavior.Strict);
            mockCinemaWorldService.Setup(s => s.GetMovieList()).ReturnsAsync(cinemaWorldMovies);


            List <MovieDetails> filmWorldMovies = new List <MovieDetails>();

            filmWorldMovies.Add(new MovieDetails {
                ID = "fw789", Title = "HOBBIT 1", Price = 41
            });
            filmWorldMovies.Add(new MovieDetails {
                ID = "fw456", Title = "The Shining", Price = 17
            });

            mockFilmWorldService = new Mock <IFilmWorldService>(MockBehavior.Strict);
            mockFilmWorldService.Setup(s => s.GetMovieList()).ReturnsAsync(filmWorldMovies);


            MovieProviderService movieProviderService = new MovieProviderService(mockCinemaWorldService.Object, mockFilmWorldService.Object);

            var movieList = await movieProviderService.GetMovies();

            Assert.AreEqual(movieList.Count(m => m.Title == "HOBBIT 1"), 1);
        }
Beispiel #2
0
        public async Task ShouldProviderReturnTheCheapestMovieId()
        {
            var cheapestMovieid = "fw789";

            List <MovieDetails> cinemaWorldMovies = new List <MovieDetails>();

            cinemaWorldMovies.Add(new MovieDetails {
                ID = "cw123", Title = "LOTR 2", Price = 202
            });

            mockCinemaWorldService = new Mock <ICinemaWorldService>(MockBehavior.Strict);
            mockCinemaWorldService.Setup(s => s.GetMovieList()).ReturnsAsync(cinemaWorldMovies);


            List <MovieDetails> filmWorldMovies = new List <MovieDetails>();

            filmWorldMovies.Add(new MovieDetails {
                ID = "fw789", Title = "LOTR 2", Price = 99
            });

            mockFilmWorldService = new Mock <IFilmWorldService>(MockBehavior.Strict);
            mockFilmWorldService.Setup(s => s.GetMovieList()).ReturnsAsync(filmWorldMovies);


            MovieProviderService movieProviderService = new MovieProviderService(mockCinemaWorldService.Object, mockFilmWorldService.Object);

            var movieList = await movieProviderService.GetMovies();

            Assert.AreEqual(movieList.FirstOrDefault().ID, cheapestMovieid);
        }