public void RemoveBook() { using (LinqLibraryDataContext db = new LinqLibraryDataContext(m_ConnectionString)) { Book book2 = new Book(); book2.title = "Dziady"; book2.author = "Adam Mickiewicz"; book2.yearPublished = 1834; book2.publisher = "greg"; db.AddBook(book2); int count = db.CountBooks(); Book someBook = db.GetBook("Dziady"); Assert.IsNotNull(someBook); db.DeleteBook(book2.book_ID); Assert.AreEqual(count - 1, db.CountBooks()); } }
public void AddSameBookTwoTimes() { using (LinqLibraryDataContext db = new LinqLibraryDataContext(m_ConnectionString)) { int count = db.CountBooks(); Book oim = new Book(); oim.title = "Ogniem i mieczem"; oim.author = "Henryk Sienkiewicz"; oim.yearPublished = 1884; oim.publisher = "KWE"; db.AddBook(oim); Book oim2 = new Book(); oim2.title = "Ogniem i mieczem"; oim2.author = "Henryk Sienkiewicz"; oim2.yearPublished = 1884; oim2.publisher = "KWE"; db.AddBook(oim2); Assert.AreEqual(count + 2, db.CountBooks()); db.DeleteBook(oim2.book_ID); db.DeleteBook(oim.book_ID); } }
public void AddBook() { using (LinqLibraryDataContext db = new LinqLibraryDataContext(m_ConnectionString)) { int count = db.Book.Count(); Book book1 = new Book(); book1.title = "Game of Thrones"; book1.author = "George R. R. Martin"; book1.yearPublished = 1996; book1.publisher = "Zysk i S-ka"; db.AddBook(book1); Book shouldBeGame = db.GetBook("Game of Thrones"); Assert.IsNotNull(shouldBeGame); Assert.AreEqual(shouldBeGame.title, "Game of Thrones"); Assert.AreEqual(shouldBeGame.author, "George R. R. Martin"); Assert.AreEqual(shouldBeGame.yearPublished, 1996); Assert.AreEqual(shouldBeGame.publisher, "Zysk i S-ka"); Assert.AreEqual(count + 1, db.CountBooks()); } }