public void CanUpdateDvd()
        {
            Dvd dvd  = new Dvd();
            var repo = new DvdRepositoryADO();

            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 CanUpdateADODvd()
        {
            Dvd dvdToAdd = new Dvd();
            var repo     = new DvdRepositoryADO();

            dvdToAdd.Title        = "New Dvd";
            dvdToAdd.ReleaseYear  = 2000;
            dvdToAdd.DirectorName = "NewDirector";
            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 = "EvenNewerDirector";
            dvdToAdd.RatingName   = "PG";
            dvdToAdd.Notes        = "This is my new note for new dvd";
            repo.Update(dvdToAdd);

            var updatedDvd = repo.GetById(5);

            Assert.AreEqual("A New Title for New Dvd", updatedDvd.Title);
            Assert.AreEqual(2001, updatedDvd.ReleaseYear);
            Assert.AreEqual("EvenNewerDirector", updatedDvd.DirectorName);
            Assert.AreEqual("PG", updatedDvd.RatingName);
            Assert.AreEqual("This is my new note for new dvd", updatedDvd.Notes);
        }
        public void CanEditDvd(int id, string title, int year, string director, string rating, string notes, bool expected)
        {
            DvdRepositoryADO repo = new DvdRepositoryADO();

            Dvd edit = new Dvd()
            {
                DvdId = id, 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);
        }
        public void CanLoadDvdById()
        {
            var repo = new DvdRepositoryADO();
            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);
        }
        public void CanDeleteDvd()
        {
            Dvd dvd  = new Dvd();
            var repo = new DvdRepositoryADO();

            repo.Delete(4);

            var dvds = repo.GetAll();

            Assert.AreEqual(13, dvds.Count());
            Assert.AreEqual(null, repo.GetById(4));
        }
예제 #6
0
        public void CanLoadADODvd()
        {
            var repo = new DvdRepositoryADO();
            var dvd  = repo.GetById(1);

            Assert.IsNotNull(dvd);
            Assert.AreEqual(1, dvd.DvdId);
            Assert.AreEqual("Manhattan", dvd.Title);
            Assert.AreEqual(1979, dvd.ReleaseYear);
            Assert.AreEqual("Allen", dvd.DirectorName);
            Assert.AreEqual("PG-13", dvd.RatingName);
            Assert.AreEqual("A Woody Allen classic", dvd.Notes);
        }
예제 #7
0
        public void CanDeleteADODvd()
        {
            Dvd DvdToAdd = new Dvd();
            var repo     = new DvdRepositoryADO();

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

            repo.Insert(DvdToAdd);

            var loaded = repo.GetById(5);

            Assert.IsNotNull(loaded);

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

            Assert.IsNull(loaded);
        }
예제 #8
0
        public void ADOGetDvdById()
        {
            var repo = new DvdRepositoryADO();
            int id   = 1;
            var dvd  = repo.GetById(id);

            Assert.AreEqual(1, dvd.DvdId);
            Assert.AreEqual("That one movie", dvd.Title);
            Assert.AreEqual(1995, dvd.ReleaseYear);
            Assert.AreEqual("Jingleheimer", dvd.Director);
            Assert.AreEqual("G", dvd.Rating);
            Assert.AreEqual("It was ok", dvd.Notes);
        }
        public void CanGetById(int id, bool expected)
        {
            DvdRepositoryADO repo = new DvdRepositoryADO();

            Dvd result = repo.GetById(id);

            bool actual;

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

            Assert.AreEqual(expected, actual);
        }
예제 #10
0
        public void ADOCanEditDvd()
        {
            var    repo         = new DvdRepositoryADO();
            int    dvdId        = 1;
            string title        = "Updated Dvd";
            int    releaseYear  = 1990;
            string directorName = "Jacob";
            string ratingName   = "PG-13";
            string notes        = "This has been updated";

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

            var updatedDvd = repo.GetById(1);

            Assert.AreEqual(1, updatedDvd.DvdId);
            Assert.AreEqual("Updated Dvd", updatedDvd.Title);
            Assert.AreEqual(1990, updatedDvd.ReleaseYear);
            Assert.AreEqual("Jacob", updatedDvd.Director);
            Assert.AreEqual("PG-13", updatedDvd.Rating);
            Assert.AreEqual("This has been updated", updatedDvd.Notes);
        }
        public void CanAddDvd(string title, int year, string director, string rating, string notes, bool expected)
        {
            DvdRepositoryADO repo = new DvdRepositoryADO();

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

            repo.AddDvd(dvd);

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

            bool actual = (fromRepo != null &&
                           dvd.Title == fromRepo.Title &&
                           dvd.RealeaseYear == fromRepo.RealeaseYear &&
                           dvd.Director == fromRepo.Director &&
                           dvd.Rating == fromRepo.Rating &&
                           dvd.Notes == fromRepo.Notes);

            Assert.AreEqual(expected, actual);
        }