using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using BookShopOnline.Model;
using BookShopOnline.Bll;
using BookShopOnline.Utility;
using NUnit.Framework;

namespace BookShopOnline.TestClass
{
    [TestFixture]
    public class TestBookBll
    {
        #region 获取某一类别及其所有子类别的图书记录(分页）
        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按销售量排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageBySoldCount()
        {
            int recordCount=0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageBySoldCount("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }

        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按访问量排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageByVisitedCount()
        {
            int recordCount = 0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageByVisitedCount("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }

        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按销售价格排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageBySellPrice()
        {
            int recordCount = 0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageBySellPrice("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }

        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按折扣排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageBySellOff()
        {
            int recordCount = 0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageBySellOff("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }

        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按发行时间排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageByDatePressed()
        {

            int recordCount = 0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageByDatePressed("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }

        [Test]
        /// <summary>
        /// 获取某一类别及其所有子类别的图书记录(分页）按上架排序
        /// </summary>
        public void TestSelectBookByBookTypeIDListByPageByDateAdded()
        {
            int recordCount = 0;
            DataSet ds = new BookBll().SelectBookByBookTypeIDListByPageByDateAdded("85", 1, true, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count > 0 && recordCount > 0);
        }
        #endregion

        #region 搜索图书（分页）
        [Test]
        public void TestSelectBookBySearchByPage()
        {
            string keyWord="test";
            string searchType="1";
            int pageIndex=1;
            string orderByField=BookOrderByFields.SellPrice;
            bool isDesc=true;
            int recordCount=0;

            DataSet ds = new BookBll().SelectBookBySearchByPage(keyWord, searchType, pageIndex, orderByField, isDesc, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count>0);
            Assert.IsTrue(recordCount>0);
        }

        [Test]
        public void TestSelectBookBySearchByPage2()
        {
            string keyWord = "";
            string searchType = "1";
            int pageIndex = 1;
            string orderByField = BookOrderByFields.SellPrice;
            bool isDesc = true;
            int recordCount = 0;

            DataSet ds = new BookBll().SelectBookBySearchByPage(keyWord, searchType, pageIndex, orderByField, isDesc, out recordCount);

            Assert.IsTrue(ds.Tables[0].Rows.Count>0);
            Assert.IsTrue(recordCount >0);
        }
        #endregion
    }
}
