public void CorrectSortByTtileMethodsSortsTheMoviesFromTheDataBaseByAlphabeticalOrder_FromAToZ()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.SortMoviesByTitle();
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectFilterMoviesByDurationAndPGFiltersTheMovieInTheDataBase()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.FilterMoviesByDurationAndPG(2, 12);
            }
            catch (Exception)
            {
                Assert.Pass();
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectSortByDateMethodSortsTheMoviesFromTheDataBaseByTheirPrimierDate_FromTheOldesToNewest()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.SortByDate();
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectEditMovieUpdatesACertainMovieInTheDataBase()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.EditMovie(4, "Movie", 7, 18, DateTime.Now, "summary...", new byte[90], 93);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectSetMovieInformationSetsTheInformationOfTheMovies()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.SetMovieInformation();
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectSetMovieTitleSetsTheTitleOfACertainMovie()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.SetMovieTitle(2);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectGetMoviesTitlesReturnsTheTtitlesOfTheMoviesFromTheDataBaseAsAList()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.GetMovieTitles();
            }
            catch (Exception)
            {
                Assert.Pass();
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectGetUserInfoMethodReturnsTheIdAndThePositionOfACertainUser()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.GetUserInfo("petya", "myPass");
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectReturnsTheIdOfTheGenreByItsName()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.GetMovieGenre("Drama");
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectGetMovieReturnsAMovieAsATuple()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.GetMovie(2);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectDeleteMovieDeletsAovieFromTheDataBase()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.DeleteMovie(1);
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
        public void CorrectGetMoviesByTitleReturnsTheMoviesFromTheDataBaseByTheirTitles()
        {
            DummyMockedAllMoviesService dummy           = new DummyMockedAllMoviesService();
            IAllMoviesPresenter         movie_presenter = new AllMoviesPresenter(dummy._iallMoviesService);

            try
            {
                movie_presenter.GetMoviesByTitle(new List <string> {
                    "Terminator", "Titanic"
                });
            }
            catch (Exception)
            {
                Assert.IsTrue(false);
            }
            finally
            {
                Assert.IsTrue(true);
            }
        }
Exemple #13
0
        /// <summary>
        /// The <c>ValidateMovieUpdate()</c> method receives as parameters - a certain movie's
        /// title, genre, parental gidness, prime date, summary and wrapper and uses the private
        /// methods for validation of this class in order to check whether all fields for
        /// updating a certain movie are correctly filled.
        /// </summary>
        /// <param name="title">This is the title of the movie.</param>
        /// <param name="genre">This is the genre of the movie.</param>
        /// <param name="pg">This is the parental guidness of the movie.</param>
        /// <param name="date">This is the prime date of the movie.</param>
        /// <param name="summary">This is the summary of the movie.</param>
        /// <param name="wrapper">This is the wrapper of the movie.</param>
        /// <exception cref="Mov4e.Exceptions.InvalidFieldInputException">Throw when
        /// any of the fields are incorectly filled.</exception>
        /// <remarks>When the exception is thrown this methods writes the error in the error.txt file.</remarks>
        public static void ValidateMovieUpdate(int id, string title, int genre, Nullable <int> pg,
                                               Nullable <DateTime> date, string summary, byte[] wrapper, int dur)
        {
            if (ValidateId(id) && ValidateTitle(title) && ValidateGenre(genre) && ValidatePG(pg) &&
                ValidateDate(date) && ValidateSummary(summary) && ValidateWrapper(wrapper) && ValidateDuration(dur))
            {
                IAllMoviesPresenter all_movies_presenter = new AllMoviesPresenter();
                all_movies_presenter.EditMovie(id, title, genre, (int)pg, date, summary, wrapper, dur);
                MessageBox.Show("You successfully updated this movie!", "Movie's Information",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("All fields are required! For more information about that " +
                                "check the errors.txt file, please!", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                Logger.Logger.WriteToLogFile(DateTime.Now.ToString() + " You tried to update a movie but you didn't fill "
                                             + "\n" + "all fields, so the application cannot create a movie with this data! "
                                             + new InvalidFieldInputException().ToString() + "\n");

                throw new InvalidFieldInputException();
            }
        }