예제 #1
0
        public void UpdateMethodOK()
        {
            clsBookCollection AllBooks = new clsBookCollection();
            clsBook           TestItem = new clsBook();
            int PrimaryKey             = 0;

            //TestItem.BookID = 1;
            TestItem.Title           = "Oxford English Dictionary";
            TestItem.DatePublished   = Convert.ToDateTime("1/2/1884");
            TestItem.Stock           = 50;
            TestItem.Price           = 4.99F;
            TestItem.AvailableOnline = false;
            AllBooks.ThisBook        = TestItem;
            PrimaryKey      = AllBooks.Add();
            TestItem.BookID = PrimaryKey;
            //TestItem.BookID = 1;
            TestItem.Title           = "Oxford English Dictionary";
            TestItem.DatePublished   = Convert.ToDateTime("1/2/1884");
            TestItem.Stock           = 100;
            TestItem.Price           = 4.99F;
            TestItem.AvailableOnline = false;
            AllBooks.ThisBook        = TestItem;
            AllBooks.Update();
            AllBooks.ThisBook.Find(PrimaryKey);
            Assert.AreEqual(AllBooks.ThisBook, TestItem);
        }
예제 #2
0
        public void FilterByTitleNoneFound()
        {
            clsBookCollection FilteredBooks = new clsBookCollection();

            FilteredBooks.FilterByTitle("nonexistent book title here");
            Assert.AreEqual(0, FilteredBooks.Count);
        }
예제 #3
0
        public void CountPropertyOK()
        {
            clsBookCollection AllBooks = new clsBookCollection();
            int someCount = 2;

            AllBooks.Count = someCount;
            Assert.AreEqual(AllBooks.Count, someCount);
        }
예제 #4
0
        public void FilterByTitleMethodOK()
        {
            clsBookCollection AllBooks      = new clsBookCollection();
            clsBookCollection FilteredBooks = new clsBookCollection();

            FilteredBooks.FilterByTitle("");
            Assert.AreEqual(AllBooks.Count, FilteredBooks.Count);
        }
예제 #5
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        clsBookCollection ABook = new clsBookCollection();

        ABook.ThisBook.Find(BookID);
        ABook.Delete();
        Response.Redirect("BookList.aspx");
    }
예제 #6
0
    void DisplayBooks()
    {
        clsBookCollection Books = new clsBookCollection();

        lstBookList.DataSource     = Books.BookList;
        lstBookList.DataValueField = "BookID";
        lstBookList.DataTextField  = "Title";
        lstBookList.DataBind();
    }
예제 #7
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsBookCollection Books = new clsBookCollection();

        Books.FilterByTitle(txtFilter.Text);
        lstBookList.DataSource     = Books.BookList;
        lstBookList.DataValueField = "BookID";
        lstBookList.DataTextField  = "Title";
        lstBookList.DataBind();
    }
예제 #8
0
        public void ThisBookPropertyOK()
        {
            clsBookCollection AllBooks = new clsBookCollection();
            clsBook           TestItem = new clsBook();

            TestItem.BookID          = 1;
            TestItem.Title           = "Oxford English Dictionary";
            TestItem.DatePublished   = Convert.ToDateTime("1/2/1884");
            TestItem.Stock           = 50;
            TestItem.Price           = 4.99F;
            TestItem.AvailableOnline = false;
            AllBooks.ThisBook        = TestItem;
            Assert.AreEqual(AllBooks.ThisBook, TestItem);
        }
예제 #9
0
        public void ListAndCountOK()
        {
            clsBookCollection AllBooks = new clsBookCollection();
            List <clsBook>    TestList = new List <clsBook>();
            clsBook           TestItem = new clsBook();

            TestItem.BookID          = 1;
            TestItem.Title           = "Oxford English Dictionary";
            TestItem.DatePublished   = Convert.ToDateTime("1/2/1884");
            TestItem.Stock           = 50;
            TestItem.Price           = 4.99F;
            TestItem.AvailableOnline = false;
            TestList.Add(TestItem);
            AllBooks.BookList = TestList;
            Assert.AreEqual(AllBooks.Count, TestList.Count);
        }
예제 #10
0
        public void FilterByTitleTestDataFound()
        {
            clsBookCollection FilteredBooks = new clsBookCollection();
            bool OK = true;

            FilteredBooks.FilterByTitle("nonexistent book title here");
            if (FilteredBooks.Count == 1)
            {
                if (FilteredBooks.BookList[0].BookID != 1)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
예제 #11
0
        public void InstanceOK()
        {
            clsBookCollection AllBooks = new clsBookCollection();

            Assert.IsNotNull(AllBooks);
        }