Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 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();
            }
        }