示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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));
        }
示例#5
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);
        }
示例#6
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);
            }
        }