public void TestAddingAndDeleting() { using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString)) { rep.AddBook("nie", "nie", "nie", 2000); Book b = rep.GetBook("nie"); Assert.IsNotNull(b); rep.DeleteBook(b.book_ID); } }
public void TestGetBook() { using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString)) { rep.AddBook("nie", "nie", "nie", 2000); Book b = rep.GetBook("nie"); Book d = rep.GetBook(b.book_ID); Assert.AreEqual(b.title, d.title); rep.DeleteBook(b.book_ID); } }
public bool CreateBook(string title, int year, string publisher, string author) { using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext()) { if (title != null) { dataContext.AddBook(title, author, publisher, year); return(true); } return(false); } }
public bool CreateBook(Book book) { using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext()) { if (book != null) { dataContext.AddBook(book); return(true); } return(false); } }
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 TestUpdatingBooks() { using (LinqLibraryDataContext rep = new LinqLibraryDataContext(m_ConnectionString)) { rep.AddBook("just a book", "with some author", "publisher", 2002); Book hello = rep.GetBook("just a book"); rep.UpdateAuthor(hello.book_ID, "not a book"); rep.UpdatePublisher(hello.book_ID, "not a publisher"); rep.UpdateTitle(hello.book_ID, "not an author"); Book bye = rep.GetBook(hello.book_ID); Assert.AreEqual("not a book", bye.author); Assert.AreEqual("not a publisher", bye.publisher); Assert.AreEqual("not an author", bye.title); } }
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 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()); } }