public void Add_NoBooksInDatabase3Author_OneBookInsertedWithAuthor()
        {
            //Arrange
            this._ndbUnitTest.ReadXml("data/authors.xml");
            this._ndbUnitTest.PerformDbOperation(NDbUnit.Core.DbOperationFlag.Insert);
            Author author = this._dataContext.GetById<Author>(1);

            //Act
            Book book = new Book(){Name="Book 01", Price = 8, Author = author};
            this._dataContext.Add<Book>(book);

            //Assert
            DataSet dataSet = this._ndbUnitTest.GetDataSetFromDb();
        }
        public void Add_NoBooksInDatabase3Author_OneBookInsertedWithAuthor()
        {
            // Arrange
            this._ndbUnitTest.ReadXml("data/authors.xml");
            this._ndbUnitTest.PerformDbOperation(NDbUnit.Core.DbOperationFlag.Insert);
            Author author = this._dataContext.GetById<Author>(1);

            // Act
            Book book = new Book(){  Name ="Book 01", Price = 8, Author = author };
            this._dataContext.Add<Book>(book);

            // Assert
            DataSet dataSet = this._ndbUnitTest.GetDataSetFromDb();
            Assert.AreEqual(3, dataSet.Tables["authors"].Rows.Count);
            Assert.AreEqual(1, dataSet.Tables["books"].Rows.Count);

            DataRow bookDataRow = dataSet.Tables["books"].Rows[0];
            Assert.AreEqual(1, bookDataRow["author_id"]);
        }
示例#3
0
 public OrderItem(Book book)
 {
     this.Book = book;
 }
        public Book TotalBookDesc(Book bookItem, int quantity, double Desc)
        {
            Book book = new Book() { Price = (bookItem.Price * quantity)-(1.00+Desc) };

            return book;
        }
        public Book TotalBook(Book bookItem, int quantity)
        {
            Book book = new Book() { Price = bookItem.Price * quantity };

            return book;
        }