Exemplo n.º 1
0
        public void GetTotalCountGreatThanZeroTest()
        {
            ZGZY.IDAL.ILoginLog loginInfoDal = ZGZY.DALFactory.Factory.GetLoginInfoDAL();
            int count = loginInfoDal.GetTotalCount("1=1");

            Assert.Greater(count, 0);   //断言结果大于0
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="strWhere">分页条件</param>
        /// <param name="orderBy">排序列</param>
        /// <param name="order">排序方式:asc、desc</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页大小</param>
        public string GetPager(string strWhere, string orderBy, string order, int pageIndex, int pageSize)
        {
            //先查总数再执行分页方法,每次都连了两次数据库。只有这个类用的此方法分页,其他类都是调用一个带输出参数的存储过程(sp_Pager)实现的分页,一次数据库连接(输出参数就是总记录数)
            int       totalCount = dal.GetTotalCount(strWhere);
            DataTable dt         = dal.GetPager(strWhere, orderBy, order, pageIndex, pageSize);

            string strjson = ZGZY.Common.JsonHelper.ToJson(dt);

            return("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strjson + "}");
        }
Exemplo n.º 3
0
        [Test] //测试方法必须无参无返回值
        public void GetTotalCountIsZeroTest()
        {
            ZGZY.IDAL.ILoginLog loginInfoDal = ZGZY.DALFactory.Factory.GetLoginInfoDAL();  //数据库访问对象
            int count = loginInfoDal.GetTotalCount("1=1");

            //得到日志器
            ILog log = log4net.LogManager.GetLogger(typeof(LoginLogTest));

            //记录日志
            log.InfoFormat("获取的个数是:{0}", count); //Info级别

            Assert.AreEqual(count, 0);           //断言结果等于0
        }