コード例 #1
0
        public void InsertShouldAddFilmsToTable()
        {
            IFilmRepository sut   = new SqlFilmRepository();
            Film            film1 = new Film("Jurassica", new DateTime(1986, 1, 20), 5, Genre.Science_Fiction);
            Film            film2 = new Film("Comando", new DateTime(1986, 1, 20), 5, Genre.Science_Fiction);

            //Act
            long id1 = sut.Insert(film1);
            long id2 = sut.Insert(film2);

            Assert.AreEqual(film1, sut.SelectById(id1), "Assertion 1");
            Assert.AreEqual(film2, sut.SelectById(id2), "Assertion 2");
        }
コード例 #2
0
        public void SqlFilmRepository_IT()
        {
            IFilmRepository sut = new SqlFilmRepository();

            Assert.AreEqual(5, sut.SelectAll().Count, "Assertion 1 ");
            Assert.AreEqual(2, sut.SearchByTitle("The").Count, "Assertion 2");
            Assert.AreEqual("Damien", sut.SelectByTitle("Damien").Title, "Assertion 3");

            Film film1 = new Film("Jurassica", new DateTime(1986, 1, 20), 5, Genre.Science_Fiction);
            Film film2 = new Film("Comando", new DateTime(1986, 1, 20), 5, Genre.Science_Fiction);

            //Act
            long id1 = sut.Insert(film1);
            long id2 = sut.Insert(film2);

            Assert.AreEqual(film1.Title, sut.SelectById(id1).Title, "Assertion 4");
            Assert.AreEqual(film2.Title, sut.SelectById(id2).Title, "Assertion 5");

            film1       = sut.SelectById(id1);
            film1.Stock = 0;
            sut.Update(film1);
            Assert.AreEqual(0, sut.SelectById(id1).Stock, "Assertion 6");

            sut.Delete(sut.SelectById(id2));
            Assert.IsNull(sut.SelectById(id2), "Assertion 7");
        }