Ejemplo n.º 1
0
        static void grid_GridRowBound(object sender, WebGrid.Events.GridRowBoundEventArgs e)
        {
            object myvalue = e.Row["intTest"].Value;

            //int type was was retrieved from data source
            if (myvalue == null)
            {
                return;
            }
            Assert.AreSame(myvalue.GetType(), typeof(int));

            //Number is 'long' type
            int?inttest = e.Row["intTest"].Value as int?;

            // Since we casted the value it should now be 'long' type
            //  myvalue = e.Row["intTest"].Value;
            //   Assert.AreSame(myvalue.GetType(), typeof(long));
            Assert.IsNotNull(inttest);
            Assert.Greater(inttest, 1);

            myvalue = e.Row["decTest"].Value;
            //Decimal type was was retrieved from data source
            Assert.AreSame(myvalue.GetType(), typeof(System.Decimal));

            decimal?dectest = e.Row["decTest"].Value as decimal?;

            Assert.IsNotNull(dectest);
            Assert.Greater(dectest, 1);

            string txttest = e.Row["vchtest"].Value as string;

            Assert.IsNotNull(txttest);


            myvalue = e.Row["dtmDate"].Value;
            //DateTime type was was retrieved from data source
            Assert.AreSame(myvalue.GetType(), typeof(System.DateTime));
            DateTime?dtmtest = e.Row["dtmDate"].Value as DateTime?;

            Assert.IsNotNull(dtmtest);
            Assert.GreaterOrEqual(dtmtest, new DateTime(2009, 1, 1));
        }
Ejemplo n.º 2
0
 static void grid_RowPrimaryKeyCheck(object sender, WebGrid.Events.GridRowBoundEventArgs e)
 {
     Assert.IsNotEmpty(e.Row.PrimaryKeyValues);
     Assert.AreEqual(e.Row.PrimaryKeyValues.Split(',').Length, 2);
 }