Beispiel #1
0
        public void CanSearchByDirector()
        {
            var repo = new DvdRepositoryMock();
            var dvds = repo.GetBySearch("director", "Peter Jackson");

            Assert.AreEqual(2, dvds.Count());
        }
Beispiel #2
0
        public void CanEditDvd(int id, string title, int year, string director, string rating, string notes, bool expected)
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();

            Dvd edit = new Dvd()
            {
                Title = title, Director = director, RealeaseYear = year, Rating = rating, Notes = notes
            };

            repo.EditDvd(edit, id);

            Dvd dvd = repo.GetById(id);

            bool actual;

            if (dvd == null)
            {
                actual = false;
            }
            else
            {
                actual = (dvd.DvdId == id &&
                          dvd.Title == title &&
                          dvd.RealeaseYear == year &&
                          dvd.Director == director &&
                          dvd.Rating == rating &&
                          dvd.Notes == notes);
            }

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void MockCanLoadDvds()
        {
            var repo = new DvdRepositoryMock();
            var test = repo.GetAllDvd();

            Assert.AreEqual(2, test.Count());
        }
Beispiel #4
0
        public void CanSearchByTitle()
        {
            var repo = new DvdRepositoryMock();
            var dvds = repo.GetBySearch("title", "Fight Club");

            Assert.AreEqual(1, dvds.Count());
        }
Beispiel #5
0
        public void MockCanLoadDirector()
        {
            var repo = new DvdRepositoryMock();
            var test = repo.GetDirectors();

            Assert.AreEqual(3, test.Count());
        }
Beispiel #6
0
        public void CanSearchByRating()
        {
            var repo = new DvdRepositoryMock();
            var dvds = repo.GetBySearch("rating", "R");

            Assert.AreEqual(6, dvds.Count());
        }
Beispiel #7
0
        public void MockCanLoadRating()
        {
            var repo = new DvdRepositoryMock();
            var test = repo.GetRatings();

            Assert.AreEqual(5, test.Count());
        }
Beispiel #8
0
        public void CanGetAll(bool expected)
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();

            var allDvds = repo.GetAll();

            bool actual = allDvds != null;

            while (actual)
            {
                actual = allDvds[0].DvdId == 1;
                actual = allDvds[0].Title == "Mad Max: Fury Road";
                actual = allDvds[0].RealeaseYear == 2015;
                actual = allDvds[0].Director == "George Miller";
                actual = allDvds[0].Rating == "R";
                actual = allDvds[0].Notes == "Some critics say \"Thirty-six viewings in a row is the only reasonable way to watch this film.\"";
                actual = allDvds[9].DvdId == 10;
                actual = allDvds[9].Title == "Boyz N The Hood";
                actual = allDvds[9].RealeaseYear == 1992;
                actual = allDvds[9].Director == "John Singleton";
                actual = allDvds[9].Rating == "R";
                actual = allDvds[9].Notes == "";
                break;
            }

            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void CanUpdateDvd()
        {
            Dvd dvd  = new Dvd();
            var repo = new DvdRepositoryMock();

            dvd.Title       = "The Lord of the Rings: The Two Towers";
            dvd.ReleaseYear = 2002;
            dvd.Director    = "Peter Jackson";
            dvd.Rating      = "PG-13";
            dvd.Notes       = "While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard.";

            repo.Insert(dvd);
            dvd = repo.GetById(15);

            dvd.Title       = "Goodfellas";
            dvd.ReleaseYear = 1990;
            dvd.Director    = "Martin Scorsese";
            dvd.Rating      = "R";
            dvd.Notes       = "The story of Henry Hill and his life through the teen years into the years of mafia, covering his relationship with his wife Karen Hill and his Mob partners Jimmy Conway and Tommy DeVito in the Italian-American crime syndicate.";

            repo.Update(dvd);

            Dvd updatedDvd = repo.GetById(15);

            Assert.AreEqual("Goodfellas", updatedDvd.Title);
            Assert.AreEqual(1990, updatedDvd.ReleaseYear);
            Assert.AreEqual("Martin Scorsese", updatedDvd.Director);
            Assert.AreEqual("R", updatedDvd.Rating);
            Assert.AreEqual("The story of Henry Hill and his life through the teen years into the years of mafia, covering his relationship with his wife Karen Hill and his Mob partners Jimmy Conway and Tommy DeVito in the Italian-American crime syndicate.", updatedDvd.Notes);
        }
Beispiel #10
0
        public void CanUpdateDvdMock()
        {
            Dvd dvdToAdd = new Dvd();
            var repo     = new DvdRepositoryMock();

            dvdToAdd.Title        = "New Dvd";
            dvdToAdd.ReleaseYear  = 2000;
            dvdToAdd.DirectorName = "Director";
            dvdToAdd.RatingName   = "G";
            dvdToAdd.Notes        = "This is my new dvd";
            repo.Insert(dvdToAdd);

            dvdToAdd.Title        = "A New Title for New Dvd";
            dvdToAdd.ReleaseYear  = 2001;
            dvdToAdd.DirectorName = "New Director";
            dvdToAdd.RatingName   = "PG-13";
            dvdToAdd.Notes        = "This is my newer dvd. Nice!";
            repo.Update(dvdToAdd);

            var updatedDvd = repo.GetById(7);

            Assert.AreEqual("A New Title for New Dvd", updatedDvd.Title);
            Assert.AreEqual(2001, updatedDvd.ReleaseYear);
            Assert.AreEqual("New Director", updatedDvd.DirectorName);
            Assert.AreEqual("PG-13", updatedDvd.RatingName);
            Assert.AreEqual("This is my newer dvd. Nice!", updatedDvd.Notes);
        }
Beispiel #11
0
        public void MockCanLoadById()
        {
            var repo  = new DvdRepositoryMock();
            int dvdId = (2);
            var dvd   = repo.GetById(dvdId);

            Assert.AreEqual(2, dvd.DvdId);
        }
Beispiel #12
0
        public void MockCanLoadByRating()
        {
            var    repo   = new DvdRepositoryMock();
            string rating = "NR";
            var    dvds   = repo.GetByRating(rating);

            Assert.AreEqual(1, dvds.Count());
        }
Beispiel #13
0
        public void MockCanLoadByDirectior()
        {
            var    repo         = new DvdRepositoryMock();
            string directorName = "Mock Director";
            var    dvds         = repo.GetByDirector(directorName);

            Assert.AreEqual(1, dvds.Count());
        }
Beispiel #14
0
        public void MockCanLoadByTitle()
        {
            var    repo  = new DvdRepositoryMock();
            string title = "Mock Movie";
            var    dvds  = repo.GetByTitle(title);

            Assert.AreEqual(1, dvds.Count());
        }
Beispiel #15
0
        public void MockCanLoadByYear()
        {
            var repo        = new DvdRepositoryMock();
            int releaseYear = 2020;
            var dvds        = repo.GetByYear(releaseYear);

            Assert.AreEqual(1, dvds.Count());
        }
Beispiel #16
0
        public void CanLoadDvdsMock()
        {
            var repo = new DvdRepositoryMock();
            var dvds = repo.GetAll();

            Assert.AreEqual(6, dvds.Count);
            Assert.AreEqual("Titanic", dvds[0].Title);
            Assert.AreEqual("Cameron", dvds[2].DirectorName);
        }
Beispiel #17
0
        public void CanSearchOnRatingIdMock()
        {
            var repo  = new DvdRepositoryMock();
            var found = repo.Search(new DvdSearchParameter {
                RatingName = "PG-13"
            });

            Assert.AreEqual(1, found.Count());
        }
Beispiel #18
0
        public void CanSearchByYearMock()
        {
            var repo  = new DvdRepositoryMock();
            var found = repo.Search(new DvdSearchParameter {
                ReleaseYear = 1990
            });

            Assert.AreEqual(1, found.Count());
        }
Beispiel #19
0
        public void CanSearchByTitleMock()
        {
            var repo  = new DvdRepositoryMock();
            var found = repo.Search(new DvdSearchParameter {
                Title = "Titanic"
            });

            Assert.AreEqual(1, found.Count());
        }
Beispiel #20
0
        public void CanSearchByDirectorNameMock()
        {
            var repo  = new DvdRepositoryMock();
            var found = repo.Search(new DvdSearchParameter {
                DirectorName = "Cameron"
            });

            Assert.AreEqual(2, found.Count());
        }
Beispiel #21
0
        public void CanLoadDvdById()
        {
            var repo = new DvdRepositoryMock();
            Dvd dvd  = repo.GetById(5);

            Assert.AreEqual("12 Angry Men", dvd.Title);
            Assert.AreEqual(1957, dvd.ReleaseYear);
            Assert.AreEqual("Sidney Lumet", dvd.Director);
            Assert.AreEqual("PG", dvd.Rating);
            Assert.AreEqual("A jury holdout attempts to prevent a miscarriage of justice by forcing his colleagues to reconsider the evidence.", dvd.Notes);
        }
Beispiel #22
0
        public void MockCanDeleteDvd()
        {
            var repo = new DvdRepositoryMock();
            var test = repo.GetAllDvd();

            Assert.AreEqual(3, test.Count());
            repo.Delete(3);
            test = repo.GetAllDvd();

            Assert.AreEqual(2, test.Count());
        }
Beispiel #23
0
        public void CanDeleteDvd()
        {
            Dvd dvd  = new Dvd();
            var repo = new DvdRepositoryMock();

            repo.Delete(4);

            var dvds = repo.GetAll();

            Assert.AreEqual(13, dvds.Count());
            Assert.AreEqual(null, repo.GetById(4));
        }
Beispiel #24
0
        public void CanLoadDvdDetailMock()
        {
            var repo = new DvdRepositoryMock();
            var dvd  = repo.GetDetails(1);

            Assert.AreEqual(1, dvd.DvdId);
            Assert.AreEqual("Titanic", dvd.Title);
            Assert.AreEqual(1997, dvd.ReleaseYear);
            Assert.AreEqual("Cameron", dvd.DirectorName);
            Assert.AreEqual("PG-13", dvd.RatingName);
            Assert.AreEqual("Must see movie.", dvd.Notes);
        }
Beispiel #25
0
        public void CanLoadDvds()
        {
            var repo = new DvdRepositoryMock();

            var dvds = repo.GetAll().ToList();

            Assert.AreEqual(14, dvds.Count());

            Assert.AreEqual("12 Angry Men", dvds[4].Title);
            Assert.AreEqual(1957, dvds[4].ReleaseYear);
            Assert.AreEqual("Sidney Lumet", dvds[4].Director);
            Assert.AreEqual("PG", dvds[4].Rating);
            Assert.AreEqual("A jury holdout attempts to prevent a miscarriage of justice by forcing his colleagues to reconsider the evidence.", dvds[4].Notes);
        }
Beispiel #26
0
        public void ResetData()
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();
            List <Dvd>        dvds = repo.GetAll().ToList();

            foreach (var d in dvds)
            {
                repo.DeleteDvd(d.DvdId);
            }

            List <Dvd> dvdLibrary = new List <Dvd>()
            {
                new Dvd {
                    DvdId = 1, Title = "Mad Max: Fury Road", RealeaseYear = 2015, Director = "George Miller", Rating = "R", Notes = "Some critics say \"Thirty-six viewings in a row is the only reasonable way to watch this film.\""
                },
                new Dvd {
                    DvdId = 2, Title = "They Live!", RealeaseYear = 1988, Director = "John Carpenter", Rating = "R", Notes = "A great documentary detailing the inner workings of current government."
                },
                new Dvd {
                    DvdId = 3, Title = "Death Proof", RealeaseYear = 2007, Director = "Quentin Tarantino", Rating = "R", Notes = "Kurt Russell plays a lady's man who valiance makes women swoon."
                },
                new Dvd {
                    DvdId = 4, Title = "Army of Darkness", RealeaseYear = 1992, Director = "Sam Raimi", Rating = "R", Notes = "\"If you don't like this movie, we could never be friends.\" - Riley Gartner, whilst coding this program."
                },
                new Dvd {
                    DvdId = 5, Title = "The Thing", RealeaseYear = 1982, Director = "John Carpenter", Rating = "R", Notes = "The only horror movie. Every other horror movie is just an over-dramatic thiller"
                },
                new Dvd {
                    DvdId = 6, Title = "pi", RealeaseYear = 1997, Director = "Darren Aronofsky", Rating = "R", Notes = Math.PI.ToString()
                },
                new Dvd {
                    DvdId = 7, Title = "Big Trouble in Little China", RealeaseYear = 1995, Director = "John Carpenter", Rating = "PG-13", Notes = "Rated top choice by several Women's lifestyles publications as the perfect film to watch with your love interest."
                },
                new Dvd {
                    DvdId = 8, Title = "Enter The Dragon", RealeaseYear = 1973, Director = "Robert Clouse", Rating = "R", Notes = "The film that ended the argument of whether Chuck Norris or Bruce Lee would win in a fight."
                },
                new Dvd {
                    DvdId = 9, Title = "Labyrinth", RealeaseYear = 1999, Director = "Jim Henson", Rating = "PG", Notes = "If you didn't watch this film between ages 1-12, your parents deprived you of a childhood. Also, emulating David Bowie's magic dance is guaranteed to land you a date."
                },
                new Dvd {
                    DvdId = 10, Title = "Boyz N The Hood", RealeaseYear = 1992, Director = "John Singleton", Rating = "R", Notes = ""
                }
            };

            foreach (var d in dvdLibrary)
            {
                repo.AddDvd(d);
            }
        }
Beispiel #27
0
        public void MockCanAddDvd()
        {
            var repo = new DvdRepositoryMock();

            string title        = "A new movie";
            int    releaseYear  = 2000;
            string directorName = "John";
            string ratingName   = "G";
            string notes        = "A note";

            repo.SaveNew(title, releaseYear, directorName, ratingName, notes);
            var test = repo.GetAllDvd();

            Assert.AreEqual(3, test.Count());
        }
Beispiel #28
0
        public void CanDeleteDvd(int id, bool expected)
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();

            bool actual = repo.GetAll().Any(d => d.DvdId == id);

            if (actual)
            {
                repo.DeleteDvd(id);

                actual = !(repo.GetAll().Any(d => d.DvdId == id));
            }

            Assert.AreEqual(expected, actual);
        }
Beispiel #29
0
        public void CanAddDvd()
        {
            Dvd dvd  = new Dvd();
            var repo = new DvdRepositoryMock();

            dvd.Title       = "The Lord of the Rings: The Two Towers";
            dvd.ReleaseYear = 2002;
            dvd.Director    = "Peter Jackson";
            dvd.Rating      = "PG-13";
            dvd.Notes       = "While Frodo and Sam edge closer to Mordor with the help of the shifty Gollum, the divided fellowship makes a stand against Sauron's new ally, Saruman, and his hordes of Isengard.";

            repo.Insert(dvd);

            Assert.AreEqual(15, dvd.DvdId);
            Assert.AreEqual("The Lord of the Rings: The Two Towers", dvd.Title);
        }
Beispiel #30
0
        public void CanGetById(int id, bool expected)
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();

            Dvd result = repo.GetById(id);

            bool actual;

            if (result == null)
            {
                actual = false;
            }
            else
            {
                actual = (result.DvdId == id);
            }

            Assert.AreEqual(expected, actual);
        }