Beispiel #1
0
        public void GetJQGridDataTableTest()
        {
            //arrange
            IDataBaseServer DB = new Server.Fakes.StubIDataBaseServer()
            {
                ExecuteDatatableStringStringDictionaryOfStringObjectOutIDataParameterArrayCommandTypeIDbTransaction = (string connectionString, string commandText, out Dictionary <string, object> outParameters, IDataParameter[] commandParameters, CommandType commandType, IDbTransaction transaction) =>
                {
                    DataTable Table = new DataTable();
                    Table.Columns.AddRange(new DataColumn[] {
                        new DataColumn("ID", typeof(int)),
                        new DataColumn("Name", typeof(string)),
                        new DataColumn("Total", typeof(float)),
                        new DataColumn("Date", typeof(DateTime)),
                        new DataColumn("IsEnable", typeof(bool))
                    });
                    DataRow Row1 = Table.NewRow();
                    Row1[0] = 1;
                    Row1[1] = "用户1";
                    Row1[2] = 12.34;
                    Row1[3] = DateTime.Today;
                    Row1[4] = false;
                    Table.Rows.Add(Row1);
                    DataRow Row2 = Table.NewRow();
                    Row2[0] = 2;
                    Row2[1] = "用户2";
                    Row2[2] = 3.4;
                    Row2[3] = DateTime.Today.AddDays(2);
                    Row2[4] = true;
                    Table.Rows.Add(Row2);
                    outParameters = new Dictionary <string, object>();
                    outParameters.Add("@Count", 2);
                    return(Table);
                }
            };

            JQGridEntity Entity = new JQGridEntity();
            JQGridServer Server = new JQGridServer(DB, "");

            //act
            DataTable Result   = Server.GetJQGridDataTable(Entity);
            int       RowCount = Convert.ToInt32(Result.ExtendedProperties["ROWCOUNT"]);

            //assert
            Assert.AreEqual(2, Result.Rows.Count);
            Assert.AreEqual(1, int.Parse(Result.Rows[0][0].ToString()));
            Assert.AreEqual("用户1", Result.Rows[0][1].ToString());
            Assert.AreEqual(12.34f, float.Parse(Result.Rows[0][2].ToString()));
            Assert.AreEqual(DateTime.Today, DateTime.Parse(Result.Rows[0][3].ToString()));
            Assert.AreEqual(false, bool.Parse(Result.Rows[0][4].ToString()));
            Assert.AreEqual(2, int.Parse(Result.Rows[1][0].ToString()));
            Assert.AreEqual("用户2", Result.Rows[1][1].ToString());
            Assert.AreEqual(3.4f, float.Parse(Result.Rows[1][2].ToString()));
            Assert.AreEqual(DateTime.Today.AddDays(2), DateTime.Parse(Result.Rows[1][3].ToString()));
            Assert.AreEqual(true, bool.Parse(Result.Rows[1][4].ToString()));
        }
Beispiel #2
0
        public void GetJQGridDataTableTestNull()
        {
            //arrange
            IDataBaseServer DB = new Server.Fakes.StubIDataBaseServer()
            {
                ExecuteDatatableStringStringDictionaryOfStringObjectOutIDataParameterArrayCommandTypeIDbTransaction = (string connectionString, string commandText, out Dictionary <string, object> outParameters, IDataParameter[] commandParameters, CommandType commandType, IDbTransaction transaction) =>
                {
                    DataTable Table = new DataTable();
                    outParameters = new Dictionary <string, object>();
                    outParameters.Add("@Count", 0);
                    return(Table);
                }
            };

            JQGridEntity Entity = new JQGridEntity();
            JQGridServer Server = new JQGridServer(DB, "");

            //act
            DataTable Result   = Server.GetJQGridDataTable(Entity);
            int       RowCount = Convert.ToInt32(Result.ExtendedProperties["ROWCOUNT"]);

            //assert
            Assert.AreEqual(0, Result.Rows.Count);
        }
Beispiel #3
0
        /// <summary>
        /// 获取分页的数据表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public DataTable GetJQGridDataTable(JQGridModel model)
        {
            JQGridEntity Entity = model.ToEntity <JQGridModel, JQGridEntity>();

            return(_jQGridServer.GetJQGridDataTable(Entity));
        }