Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 public bool RemoveBook(int ID)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         Book book = dataContext.GetBook(ID);
         if (book != null)
         {
             dataContext.DeleteBook(ID);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 5
0
 public bool DeleteBookByTitle(string title)
 {
     using (LinqLibraryDataContext dataContext = new LinqLibraryDataContext())
     {
         Book book = dataContext.GetBook(title);
         if (book != null)
         {
             dataContext.DeleteBook(book.book_ID);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 6
0
        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());
            }
        }