public void CorrectAddMovieSuccessfullyAddsAMovieInTheDataBase() { DummyMockedNewMovieService dummy = new DummyMockedNewMovieService(); INewMoviePresenter movie_presenter = new NewMoviePresenter(dummy._inewMovieService); try { movie_presenter.AddMovie("Movie", 6, 14, DateTime.Now, "summary...", new byte[65], 123); } catch (Exception) { Assert.Pass(); } finally { Assert.IsTrue(true); } }
public void CorrectLastMovieIdReturnsTheIdOfTheLastAddedMovieId() { DummyMockedNewMovieService dummy = new DummyMockedNewMovieService(); INewMoviePresenter movie_presenter = new NewMoviePresenter(dummy._inewMovieService); try { movie_presenter.LastMovieId(); } catch (Exception) { Assert.Pass(); } finally { Assert.IsTrue(true); } }
/// <summary> /// The <c>ValidateNewMovie()</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 /// creating a new 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 ValidateNewMovie(string title, int genre, Nullable <int> pg, Nullable <DateTime> date, string summary, byte[] wrapper, int dur) { INewMoviePresenter movie_presenter = new NewMoviePresenter(); if (ValidateTitle(title) && ValidateGenre(genre) && ValidatePG(pg) && ValidateDate(date) && ValidateSummary(summary) && ValidateWrapper(wrapper) && ValidateDuration(dur)) { movie_presenter.AddMovie(title, genre, pg, date, summary, wrapper, dur); MessageBox.Show("You successfully added a new movie!", "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 add new 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(); } }