Esempio n. 1
0
        public void WebGridLinqTest2()
        {
            NorthwindEmployeeData employeedata = new NorthwindEmployeeData();

            Collection <NorthwindEmployee> employees = employeedata.GetAllEmployeesCollection("", 0, 100);

            var list = from test in employees
                       where test.Region != "WA"
                       select new { test.EmployeeID, test.FirstName };

            Grid grid = new Grid();

            grid.DataSource = list;
            grid.ID         = "test";
            int            rows       = grid.Rows.Count; // Return 5 rows.
            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, 1);
            Assert.AreEqual(rows, 4);
            foreach (WebGrid.Data.Row row in grid.Rows)
            {
                Assert.IsNotNull(row["EmployeeID"].Value);
                Assert.IsNotNull(row["FirstName"].Value);
                Assert.AreEqual(row["FirstName"].Value.GetType(), typeof(string));
                // WebGrid is using int64
                Assert.AreEqual(row["EmployeeID"].Value.GetType(), typeof(Int64));
            }
        }
Esempio n. 2
0
        public void LoadGridWithEmployeesGenericCollection()
        {
            NorthwindEmployeeData employeedata = new NorthwindEmployeeData();

            Collection<NorthwindEmployee> employees = employeedata.GetAllEmployeesCollection("", 0, 100);

            Grid grid = new Grid();
            grid.DataSource = employees;
            grid.ID = "test";
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, employees.Count);
        }
Esempio n. 3
0
        public void LoadGridWithEmployeesGenericCollection()
        {
            NorthwindEmployeeData employeedata = new NorthwindEmployeeData();

            Collection <NorthwindEmployee> employees = employeedata.GetAllEmployeesCollection("", 0, 100);
            Grid grid = new Grid();

            grid.DataSource = employees;
            grid.ID         = "test";
            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            grid.RenderControl(gridwriter);
            Assert.AreEqual(grid.MasterTable.Rows.Count, employees.Count);
        }
Esempio n. 4
0
        public void WebGridLinqTest2()
        {
            NorthwindEmployeeData employeedata = new NorthwindEmployeeData();

            Collection<NorthwindEmployee> employees = employeedata.GetAllEmployeesCollection("", 0, 100);

            var list = from test in employees
                       where test.Region != "WA"
                       select new { test.EmployeeID, test.FirstName };

            Grid grid = new Grid();
            grid.DataSource = list;
            grid.ID = "test";
            int rows = grid.Rows.Count; // Return 5 rows.
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);
            grid.RenderControl(gridwriter);
            Assert.Greater(grid.MasterTable.Rows.Count, 1);
            Assert.AreEqual(rows, 4);
            foreach (WebGrid.Data.Row row in grid.Rows)
            {
                Assert.IsNotNull(row["EmployeeID"].Value);
                Assert.IsNotNull(row["FirstName"].Value);
                Assert.AreEqual(row["FirstName"].Value.GetType(), typeof(string));
                // WebGrid is using int64
                Assert.AreEqual(row["EmployeeID"].Value.GetType(), typeof(Int64));
            }
        }