Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public void MockCanLoadById()
        {
            var repo  = new DvdRepositoryMock();
            int dvdId = (2);
            var dvd   = repo.GetById(dvdId);

            Assert.AreEqual(2, dvd.DvdId);
        }
Пример #5
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);
        }
Пример #6
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));
        }
Пример #7
0
        public void CanDeleteDvdMock()
        {
            Dvd dvdToAdd = new Dvd();
            var repo     = new DvdRepositoryMock();

            dvdToAdd.Title        = "My test Dvd";
            dvdToAdd.ReleaseYear  = 2020;
            dvdToAdd.DirectorName = "TestDirector";
            dvdToAdd.RatingName   = "R";
            dvdToAdd.Notes        = "Dvd for my test";

            repo.Insert(dvdToAdd);

            var loaded = repo.GetById(7);

            Assert.IsNotNull(loaded);

            repo.Delete(7);
            loaded = repo.GetById(7);

            Assert.IsNull(loaded);
        }
Пример #8
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);
        }
Пример #9
0
        public void MockCanEditDvd()
        {
            var    repo         = new DvdRepositoryMock();
            int    dvdId        = 2;
            string title        = "An edited movie";
            int    releaseYear  = 1999;
            string directorName = "Jacob";
            string ratingName   = "PG";
            string notes        = "A note";

            repo.Edit(dvdId, title, releaseYear, directorName, ratingName, notes);

            var test      = repo.GetAllDvd();
            var editedDvd = repo.GetById(2);

            Assert.AreEqual(2, editedDvd.DvdId);
            Assert.AreEqual("An edited movie", editedDvd.Title);
            Assert.AreEqual(1999, editedDvd.ReleaseYear);
            Assert.AreEqual("Jacob", editedDvd.Director);
            Assert.AreEqual("PG", editedDvd.Rating);
        }
Пример #10
0
        public void CanAddDvd(string title, int year, string director, string rating, string notes, bool expected)
        {
            DvdRepositoryMock repo = new DvdRepositoryMock();

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

            repo.AddDvd(dvd);

            var check = repo.GetById(dvd.DvdId);

            bool actual = check != null &&
                          check.Title == title &&
                          check.RealeaseYear == year &&
                          check.Director == director &&
                          check.Rating == rating &&
                          check.Notes == notes;

            Assert.AreEqual(expected, actual);
        }