Beispiel #1
0
        public async Task ExecuteAsync()
        {
            try
            {
                MovieWrapperBase movieWrapper = new MovieWrapperBase(VendorId);

                List <Movie> showingMovies = await movieWrapper.GetNowShowingMovies();

                Console.WriteLine(string.Format("********************* List showing movies of vendor {0} *********************", VendorId));
                foreach (var movie in showingMovies)
                {
                    Console.WriteLine(string.Format("Movie ID: {0}", movie.MovieId));
                    Console.WriteLine(string.Format("Poster Url: {0}", movie.PosterUrl));
                    Console.WriteLine(string.Format("English Name: {0}", movie.EnglishName));
                    Console.WriteLine(string.Format("VietNamese Name: {0}", movie.VietNameseName));
                    Console.WriteLine(string.Format("Play Time: {0}", movie.PlayTime));
                    if (movie.ReleaseDate != DateTime.MinValue)
                    {
                        Console.WriteLine(string.Format("Release Date: {0}", movie.ReleaseDate.ToString("dd/MM/yyyy")));
                    }
                    Console.WriteLine("-------------------------------------------------------------");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
        public void GetMovieDetail_Should_Return_Exception()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetMovieDetail(It.IsAny <string>())).Throws(new Exception("Unknow Issue"));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            // Assert
            Assert.ThrowsExceptionAsync <Exception>(() => movieWrapper.GetMovieDetail("123"), "Unknow Issue");
        }
Beispiel #3
0
        public void GetNowShowingMovies_Should_Return_Exception()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetNowShowingMovies()).Throws(new Exception("Unknow Issue"));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            // Assert
            Assert.ThrowsExceptionAsync <Exception>(() => movieWrapper.GetNowShowingMovies(), "Unknow Issue");
        }
Beispiel #4
0
        public void GetSessionOfMovie_Should_Return_NotSupportException()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetSessionOfMovie(It.IsAny <string>())).Throws(new NotSupportException("Not Support"));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            // Assert
            Assert.ThrowsExceptionAsync <Exception>(() => movieWrapper.GetSessionOfMovie("123"), "Not Support");
        }
Beispiel #5
0
        public void GetMovieDetail_Should_Return_Success()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetMovieDetail(It.IsAny <string>())).Returns(Task.FromResult(new Movie {
                MovieId = "123"
            }));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            var result = movieWrapper.GetMovieDetail("1");

            // Assert
            Assert.IsNotNull(result.Result);
            Assert.AreEqual("123", result.Result.MovieId);
        }
        public async Task ExecuteAsync()
        {
            try
            {
                MovieWrapperBase movieWrapper = new MovieWrapperBase(VendorId);

                List <SessionMovie> sessionMovies = await movieWrapper.GetSessionOfMovie(MovieId);

                Console.WriteLine(string.Format("********************* Session of movie {0} *********************", MovieId));

                foreach (var sessionMovie in sessionMovies)
                {
                    Console.WriteLine(string.Format("Cinema Name: {0}", sessionMovie.CinemaName));
                    Console.WriteLine(string.Format("Cinema Phone: {0}", sessionMovie.CinemaPhone));
                    Console.WriteLine(string.Format("Cinema Address: {0}", sessionMovie.CinemaAddress));
                    Console.WriteLine(string.Format("Longitude: {0}", sessionMovie.Longitude));
                    Console.WriteLine(string.Format("Latitude: {0}", sessionMovie.Latitude));

                    foreach (var date in sessionMovie.Dates)
                    {
                        Console.WriteLine(string.Format("-- Show Date: {0}", date.ShowDate.ToShortDateString()));
                        Console.WriteLine(string.Format("-- Day of Week: {0}", date.DayOfWeekLabel));

                        foreach (var bundle in date.Bundles)
                        {
                            Console.WriteLine(string.Format("---- Caption: {0}", bundle.Caption));
                            Console.WriteLine(string.Format("---- Version: {0}", bundle.Version));

                            foreach (var session in bundle.Sessions)
                            {
                                Console.WriteLine();
                                Console.WriteLine(string.Format("------ Seats Available: {0}", session.SeatsAvailable));
                                Console.WriteLine(string.Format("------ Screen Number: {0}", session.ScreenNumber));
                                Console.WriteLine(string.Format("------ Screen Name: {0}", session.ScreenName));
                                Console.WriteLine(string.Format("------ Show Time: {0}", session.ShowTime));
                            }
                        }
                    }
                    Console.WriteLine("-------------------------------------------------------------");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #7
0
        public void GetNowShowingMovies_Should_Return_Success()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetNowShowingMovies()).Returns(Task.FromResult(new List <Movie> {
                new Movie {
                    MovieId = "123"
                }
            }));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            var result = movieWrapper.GetNowShowingMovies();

            // Assert
            Assert.IsNotNull(result.Result);
            Assert.AreEqual(1, result.Result.Count);
        }
Beispiel #8
0
        public void GetSessionOfMovie_Should_Return_Success()
        {
            // Arrange
            vendorServiceMock.Setup(x => x.GetSessionOfMovie(It.IsAny <string>())).Returns(Task.FromResult(new List <SessionMovie> {
                new SessionMovie {
                    CinemaName = "CGV"
                }
            }));
            var movieWrapper = new MovieWrapperBase("123", vendorServiceMock.Object);

            // Action

            var result = movieWrapper.GetSessionOfMovie("1");

            // Assert
            Assert.IsNotNull(result.Result);
            Assert.AreEqual(1, result.Result.Count);
        }
Beispiel #9
0
        public async Task ExecuteAsync()
        {
            try
            {
                MovieWrapperBase movieWrapper = new MovieWrapperBase(VendorId);

                Movie movie = await movieWrapper.GetMovieDetail(MovieId);

                if (movie != null && !string.IsNullOrWhiteSpace(movie.MovieId))
                {
                    Console.WriteLine(string.Format("********************* MOVIE DETAIL of {0} *********************", MovieId));

                    Console.WriteLine(string.Format("Movie ID: {0}", movie.MovieId));
                    Console.WriteLine(string.Format("Poster Url: {0}", movie.PosterUrl));
                    if (!string.IsNullOrWhiteSpace(movie.TrailerUrl))
                    {
                        Console.WriteLine(string.Format("Trailer Url: {0}", movie.TrailerUrl));
                    }
                    Console.WriteLine(string.Format("English Name: {0}", movie.EnglishName));
                    Console.WriteLine(string.Format("VietNamese Name: {0}", movie.VietNameseName));
                    Console.WriteLine(string.Format("Play Time: {0}", movie.PlayTime));
                    Console.WriteLine(string.Format("Description: {0}", movie.Description));
                    Console.WriteLine(string.Format("View Grade Code: {0}", movie.ViewGradeCode));
                    if (!string.IsNullOrWhiteSpace(movie.MovieGenreName))
                    {
                        Console.WriteLine(string.Format("Movie Genre Name: {0}", movie.MovieGenreName));
                    }
                    if (movie.ReleaseDate != DateTime.MinValue)
                    {
                        Console.WriteLine(string.Format("Release Date: {0}", movie.ReleaseDate.ToString("dd/MM/yyyy")));
                    }
                    Console.WriteLine(string.Format("Total View Count: {0}", movie.TotalViewCount));
                }
                else
                {
                    Console.WriteLine("The movie is not exist");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }