public static void GridView_Init (Page p) { PokerGridView gv = new PokerGridView (); DS data = new DS (); p.Controls.Add (gv); p.Controls.Add (data); data.TypeName = typeof (DS).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.ID = "Data"; gv.DataBinding += new EventHandler (data_DataBinding); gv.DataSourceID = "Data"; }
public void GridView_DeleteItem () { PokerGridView g = new PokerGridView (); ArrayList myds = new ArrayList (); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); g.DataSource = myds; g.DataBind (); Assert.AreEqual (false, deleteitemchecker, "DeleteItem#1"); g.RowDeleting += new GridViewDeleteEventHandler (RowDeletingHandler); g.DeleteRow (0); Assert.AreEqual (true, deleteitemchecker, "DeleteItem#2"); }
public void GridView_CreateAutoGeneratedColumn () { PokerGridView g = new PokerGridView (); AutoGeneratedFieldProperties fp = new AutoGeneratedFieldProperties(); fp.Name = "testfield"; fp.Type = typeof (string); AutoGeneratedField gf = g.DoCreateAutoGeneratedColumn (fp); Assert.AreEqual (typeof (string), gf.DataType , "AutoGeneratedColumn#1"); Assert.AreEqual ("testfield", gf.HeaderText, "AutoGeneratedColumn#2"); Assert.AreEqual ("System.Web.UI.WebControls.AutoGeneratedField", gf.GetType ().ToString (), "AutoGeneratedColumn#3"); }
public void GridView_DataKeys () { Page p = new Page (); PokerGridView gv = new PokerGridView (); p.Controls.Add (gv); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataObject).AssemblyQualifiedName; data.SelectMethod = "Select"; p.Controls.Add (data); gv.DataSource = data; gv.DataKeyNames = new string [] { "ID", "FName" }; DataKeyArray keys1 = gv.DataKeys; Assert.AreEqual (0, keys1.Count, "DataKeys count before binding"); gv.DataBind (); DataKeyArray keys2 = gv.DataKeys; DataKeyArray keys3 = gv.DataKeys; Assert.IsFalse (Object.ReferenceEquals (keys1, keys2), "DataKey returns the same instans"); Assert.IsTrue (Object.ReferenceEquals (keys2, keys3), "DataKey returns the same instans"); Assert.AreEqual (1, keys1.Count, "DataKeys count after binding"); Assert.AreEqual (1001, keys1 [0].Value, "DataKey.Value after binding"); Assert.AreEqual (2, keys1 [0].Values.Count, "DataKey.Values count after binding"); Assert.AreEqual (1001, keys1 [0].Values [0], "DataKey.Values[0] after binding"); Assert.AreEqual ("Mahesh", keys1 [0].Values [1], "DataKey.Values[1] after binding"); PokerGridView copy = new PokerGridView (); object state = gv.DoSaveControlState (); copy.DoLoadControlState (state); DataKeyArray keys4 = copy.DataKeys; Assert.AreEqual (1, keys4.Count, "DataKeys count from ControlState"); Assert.AreEqual (1001, keys4 [0].Value, "DataKey.Value from ControlState"); Assert.AreEqual (2, keys4 [0].Values.Count, "DataKey.Values count from ControlState"); Assert.AreEqual (1001, keys4 [0].Values [0], "DataKey.Values[0] from ControlState"); Assert.AreEqual ("Mahesh", keys4 [0].Values [1], "DataKey.Values[1] from ControlState"); }
public void GridView_DataBind() { PokerGridView g = new PokerGridView (); g.DataSource = myds; g.DataBind (); Assert.AreEqual (6, g.Rows.Count, "DataBind"); g.DataSource = null; g.DataBind (); Assert.AreEqual (0, g.Rows.Count, "DataBind"); }
public void SortedDescendingHeaderStyle () { var g = new PokerGridView (); Assert.IsNotNull (g.SortedDescendingHeaderStyle, "#A1-1"); }
public void GridView_Sort_and_DataSourceSelectArguments () { DataSourceView view; DataSourceSelectArguments arg; Page p = new Page (); PokerGridView g = new PokerGridView (); g.Columns.Add (new BoundField ()); g.AllowSorting = true; p.Controls.Add (g); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.SortParameterName = "sortExpression"; data.ID = "Data"; p.Controls.Add (data); g.DataSourceID = "Data"; g.EditIndex = 2; g.PageIndex = 1; g.DataBind (); g.Sort ("sort", SortDirection.Descending); Assert.AreEqual (-1, g.EditIndex, "EditIndex after Sort, Bound by DataSourceID"); Assert.AreEqual (0, g.PageIndex, "PageIndex after Sort, Bound by DataSourceID"); arg = g.DoCreateDataSourceSelectArguments(); view = g.DoGetData (); Assert.IsTrue (view.CanSort); Assert.AreEqual ("sort", g.SortExpression, "SortExpression, Bound by DataSourceID"); Assert.AreEqual (SortDirection.Descending, g.SortDirection, "SortDirection, Bound by DataSourceID"); Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = true, Bound by DataSourceID"); g.AllowSorting = false; arg = g.DoCreateDataSourceSelectArguments (); Assert.AreEqual ("sort DESC", arg.SortExpression, "AllowSorting = false, Bound by DataSourceID"); }
public static void RenderAllowPaging (Page p) { ArrayList myds = new ArrayList (); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerGridView b = new PokerGridView (); p.Form.Controls.Add (lcb); p.Form.Controls.Add (b); b.AllowPaging = true; b.PageSize = 2; b.DataSource = myds; b.DataBind (); p.Form.Controls.Add (lce); }
public static void RenderAllowPaging2 (Page p) { ArrayList myds = new ArrayList (); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerGridView b = new PokerGridView (); p.Form.Controls.Add (lcb); p.Form.Controls.Add (b); b.AllowPaging = true; b.PageSize = 2; b.PageIndex = 1; b.PagerSettings.PageButtonCount = 4; b.PagerSettings.Mode= PagerButtons.NumericFirstLast; b.DataSource = myds; b.DataBind (); p.Form.Controls.Add (lce); }
public void GridView_DefaultsRender () { PokerGridView b = new PokerGridView (); string html = b.Render (); Assert.AreEqual(-1 ,b.Render().IndexOf("table"), "RenderViewState"); }
public void GridView_Render () { PokerGridView b = new PokerGridView (); b.DataSource = myds; b.DataBind (); string OriginControlHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">Item</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Norway</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Sweden</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>France</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Italy</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Israel</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Russia</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; string RenderedControlHtml = b.Render (); HtmlDiff.AssertAreEqual (OriginControlHtml, RenderedControlHtml, "Rendering"); }
public void GridView_State () { PokerGridView g = new PokerGridView (); PokerGridView copy = new PokerGridView (); string[] test = new String[1]; test[0] = "test"; g.DataKeyNames = test; g.EditIndex = 0; g.PageIndex = 2; object state = g.DoSaveControlState (); copy.DoLoadControlState (state); Assert.AreEqual ("test", copy.DataKeyNames[0], "DataKeyNames"); Assert.AreEqual (0, copy.EditIndex, "EditIndex"); Assert.AreEqual (2, copy.PageIndex, "PageIndex"); }
public void GridView_PrepareControlHierarchy () { PokerGridView gv = new PokerGridView (); gv.controlHierarchy = false; gv.Render (); Assert.AreEqual (0, gv.Controls.Count, "ControlHierarchy_ControlsCount"); Assert.AreEqual (true, gv.controlHierarchy, "ControlHierarchy_FirstFlow"); gv.DataSource = myds; gv.DataBind (); gv.controlHierarchy = false; gv.Render (); Assert.AreEqual (1, gv.Controls.Count, "ControlHierarchy_ControlsCountSecondaryFlow"); Assert.AreEqual (true, gv.controlHierarchy, "ControlHierarchy_SecondaryFlow"); }
public void GridView_PerformDataBiding () { PokerGridView gv = new PokerGridView (); gv.DoPerformDataBinding (myds); Assert.AreEqual (6, gv.Rows.Count, "PerformDataBiding_Rows"); }
public void GridView_AssignedProperties () { PokerGridView g = new PokerGridView (); Assert.AreEqual (0, g.StateBag.Count, "ViewState.Count"); g.AllowPaging = true; Assert.AreEqual (true, g.AllowPaging, "AllowPaging"); g.AllowSorting = true; Assert.AreEqual (true, g.AllowSorting, "AllowSorting"); g.AutoGenerateColumns = false; Assert.AreEqual (false, g.AutoGenerateColumns, "AutoGenerateColumns"); g.AutoGenerateDeleteButton = true; Assert.AreEqual (true, g.AutoGenerateDeleteButton, "AutoGenerateDeleteButton"); g.AutoGenerateEditButton = true; Assert.AreEqual (true, g.AutoGenerateEditButton, "AutoGenerateEditButton"); g.AutoGenerateSelectButton = true; Assert.AreEqual (true, g.AutoGenerateSelectButton, "AutoGenerateSelectButton"); g.BackImageUrl = "test"; Assert.AreEqual ("test", g.BackImageUrl, "BackImageUrl"); g.Caption = "test"; Assert.AreEqual ("test", g.Caption, "Caption"); g.CaptionAlign = TableCaptionAlign.Left; Assert.AreEqual (TableCaptionAlign.Left, g.CaptionAlign, "CaptionAlign"); g.CellPadding = 0; Assert.AreEqual (0, g.CellPadding, "CellPadding"); g.CellSpacing = 1; Assert.AreEqual (1, g.CellSpacing, "CellSpacing"); // ToDo: The Columns property default value is tested by the DataControlFieldCollection and DataControlField tests string[] str = new String[1]; str[0] = "test"; g.DataKeyNames = str; Assert.AreEqual ("test", g.DataKeyNames[0], "DataKeyNames"); // ToDo: The DataKeys property default value is tested by the DataKeyArray and DataKey tests g.EditIndex = 0; Assert.AreEqual (0, g.EditIndex, "EditIndex"); // The EditRowStyle property default value is tested by the TableItemStyle test (already exists) // The EmptyDataRowStyle property default value is tested by the TableItemStyle test (already exists) MyWebControl.Image myImage = new MyWebControl.Image (); myImage.ImageUrl = "myimage.jpg"; ImageTemplate template = new ImageTemplate (); template.MyImage = myImage; // end create template image g.EmptyDataTemplate = template; Assert.IsNotNull (g.EmptyDataTemplate, "EmptyDataTemplate"); g.EmptyDataText = "test"; Assert.AreEqual ("test", g.EmptyDataText, "EmptyDataText"); g.EnableSortingAndPagingCallbacks = true; Assert.AreEqual (true, g.EnableSortingAndPagingCallbacks, "EnableSortingAndPagingCallbacks"); // The FooterStyle property default value is tested by the TableItemStyle test (already exists) g.GridLines = GridLines.Horizontal; Assert.AreEqual (GridLines.Horizontal, g.GridLines, "GridLines"); g.HorizontalAlign = HorizontalAlign.Justify; Assert.AreEqual (HorizontalAlign.Justify, g.HorizontalAlign, "HorizontalAlign"); g.PageIndex = 1; Assert.AreEqual (1, g.PageIndex, "PageIndex"); // ToDo: The PagerSettings property default value is tested by the PagerSettings test // The PagerStyle property default value is tested by the TableItemStyle test (already exists) g.PagerTemplate = template; Assert.IsNotNull (g.PagerTemplate, "PagerTemplate"); g.PageSize = 5; Assert.AreEqual (5, g.PageSize, "PageSize"); g.RowHeaderColumn = "test"; Assert.AreEqual ("test", g.RowHeaderColumn, "RowHeaderColumn"); // ToDo: The Rows property default value is tested by the GridViewRowCollection and GridViewRow test // The RowStyle property default value is tested by the TableItemStyle test (already exists) g.ShowFooter = true; Assert.AreEqual (true, g.ShowFooter, "ShowFooter"); g.ShowHeader = false; Assert.AreEqual (false, g.ShowHeader, "ShowHeader"); g.UseAccessibleHeader = false; Assert.AreEqual (false, g.UseAccessibleHeader, "UseAccessibleHeader"); }
public static void RenderProperty (Page p) { // Array list for simple datasource ArrayList myds = new ArrayList (); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); // Helper controls for searching usefull data from page LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerGridView g = new PokerGridView (); // Changing some property for test g.AutoGenerateDeleteButton = true; g.AutoGenerateEditButton = true; g.BackImageUrl = "http://test"; g.Caption = "test"; g.CaptionAlign = TableCaptionAlign.Left; g.CellPadding = 0; g.CellSpacing = 1; g.EnableSortingAndPagingCallbacks = true; g.GridLines = GridLines.Horizontal; g.HorizontalAlign = HorizontalAlign.Justify; g.ShowFooter = true; g.ShowHeader = false; g.UseAccessibleHeader = false; // Add controls for page p.Form.Controls.Add (lcb); p.Form.Controls.Add (g); // Data source and bind g.DataSource = myds; g.DataBind (); p.Form.Controls.Add (lce); }
public void SortedAscendingCellStyle () { var g = new PokerGridView (); Assert.IsNotNull (g.SortedAscendingCellStyle, "#A1-1"); }
public void GridView_postback (Page p) { PokerGridView b = new PokerGridView (); b.ID = "mygrid"; b.PageIndexChanging += new GridViewPageEventHandler (b_PageIndexChanging); b.Sorting += new GridViewSortEventHandler (b_Sorting); b.RowDeleting += new GridViewDeleteEventHandler (b_RowDeleting); b.RowEditing += new GridViewEditEventHandler (b_RowEditing); ArrayList myds = new ArrayList (); myds.Add ("Norway"); myds.Add ("Sweden"); myds.Add ("France"); myds.Add ("Italy"); p.Form.Controls.Add (b); b.AllowPaging = true; b.PageSize = 2; b.AllowSorting = true; b.AutoGenerateDeleteButton = true; b.AutoGenerateEditButton = true; b.AutoGenerateSelectButton = true; b.DataSource = myds; b.DataBind (); }
public void GridView_DefaultProtectedProperties () { PokerGridView g = new PokerGridView (); Assert.AreEqual (HtmlTextWriterTag.Table, g.PTagKey, "TagKey"); }
public void GridView_GetDefaultSelectedValue () { PokerGridView g = new PokerGridView (); object o = g.SelectedValue; }
public void GridView_PageCount () { Page p = new Page (); PokerGridView gv = new PokerGridView (); gv.PageSize = 3; gv.AllowPaging = true; p.Controls.Add (gv); ObjectDataSource data = new ObjectDataSource (); data.ID = "ObjectDataSource1"; data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; p.Controls.Add (data); gv.DataSourceID = "ObjectDataSource1"; gv.SetRequiresDataBinding (true); Assert.AreEqual (0, gv.PageCount, "PageCount before binding"); gv.DataBind (); Assert.AreEqual (2, gv.PageCount, "PageCount after binding"); PokerGridView copy = new PokerGridView (); copy.DoLoadControlState (gv.DoSaveControlState ()); Assert.AreEqual (2, copy.PageCount, "PageCount from ViewState"); }
public static void GridView_RequiresDataBinding_LoadComplete (Page p) { PokerGridView grid = new PokerGridView (); p.Form.Controls.Add (grid); grid.DataSource = new string [] { "A", "B", "C" }; grid.DataBind (); Assert.AreEqual (false, grid.GetRequiresDataBinding ()); grid.EmptyDataTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, grid.GetRequiresDataBinding (), "EmptyDataTemplate was set"); grid.PagerTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, grid.GetRequiresDataBinding (), "PagerTemplate was set"); }
public void GridView_CreateDataSourceSelectArguments () { DataSourceView view; Page p = new Page (); PokerGridView g = new PokerGridView (); g.Sorting += new GridViewSortEventHandler (g_Sorting); p.Controls.Add (g); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.SortParameterName = "sortExpression"; DataSourceSelectArguments arg; p.Controls.Add (data); g.DataSource = data; g.DataBind (); arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "Default"); g.AllowPaging = true; g.PageIndex = 2; g.PageSize = 3; arg = g.DoCreateDataSourceSelectArguments (); view = g.DoGetData (); Assert.IsFalse (view.CanPage); Assert.IsTrue (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = true, CanPage = false, CanRetrieveTotalRowCount = true"); // make DataSourceView.CanPage = true data.EnablePaging = true; arg = g.DoCreateDataSourceSelectArguments (); view = g.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsFalse (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (new DataSourceSelectArguments (6, -1)), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = false"); g.AllowPaging = false; arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = false"); // make DataSourceView.CanRetrieveTotalRowCount = true data.SelectCountMethod = "GetCount"; arg = g.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = true"); g.AllowPaging = true; arg = g.DoCreateDataSourceSelectArguments (); DataSourceSelectArguments arg1 = new DataSourceSelectArguments (6, 3); arg1.RetrieveTotalRowCount = true; view = g.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsTrue (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = true"); g.AllowPaging = false; g.AllowSorting = true; g.EditIndex = 2; g.PageIndex = 1; g.Sort ("sort", SortDirection.Descending); Assert.AreEqual (2, g.EditIndex, "EditIndex after Sort, Bound by DataSource"); Assert.AreEqual (1, g.PageIndex, "PageIndex after Sort, Bound by DataSource"); arg = g.DoCreateDataSourceSelectArguments (); view = g.DoGetData (); Assert.IsTrue (view.CanSort); Assert.AreEqual (String.Empty, g.SortExpression, "SortExpression, Bound by DataSource"); Assert.AreEqual (SortDirection.Ascending, g.SortDirection, "SortDirection, Bound by DataSource"); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowSorting = true, Bound by DataSource"); }
public static void GridView_Pager_Load (Page p) { // TopAndBottom, PageCount = 1 PokerGridView grid = new PokerGridView (); grid.PagerSettings.Position = PagerPosition.TopAndBottom; grid.AllowPaging = true; p.Form.Controls.Add (grid); grid.DataSource = new string [] { "A", "B", "C" }; grid.DataBind (); Assert.AreEqual (1, grid.PageCount, "#1#PageCount"); Assert.IsNotNull (grid.TopPagerRow, "#1#TopPagerRow"); Assert.AreEqual (false, grid.TopPagerRow.Visible, "#1#TopPagerRow.Visible"); Assert.IsNotNull (grid.BottomPagerRow, "#1#BottomPagerRow"); Assert.AreEqual (false, grid.BottomPagerRow.Visible, "#1#BottomPagerRow.Visible"); // Top, PageCount = 1 grid = new PokerGridView (); grid.PagerSettings.Position = PagerPosition.Top; grid.AllowPaging = true; p.Form.Controls.Add (grid); grid.DataSource = new string [] { "A", "B", "C" }; grid.DataBind (); Assert.AreEqual (1, grid.PageCount, "#2#PageCount"); Assert.IsNotNull (grid.TopPagerRow, "#2#TopPagerRow"); Assert.AreEqual (false, grid.TopPagerRow.Visible, "#2#TopPagerRow.Visible"); Assert.IsNull (grid.BottomPagerRow, "#2#BottomPagerRow"); // Bottom, PageCount = 1 grid = new PokerGridView (); grid.PagerSettings.Position = PagerPosition.Bottom; grid.AllowPaging = true; p.Form.Controls.Add (grid); grid.DataSource = new string [] { "A", "B", "C" }; grid.DataBind (); Assert.AreEqual (1, grid.PageCount, "#3#PageCount"); Assert.IsNull (grid.TopPagerRow, "#3#TopPagerRow"); Assert.IsNotNull (grid.BottomPagerRow, "#3#BottomPagerRow"); Assert.AreEqual (false, grid.BottomPagerRow.Visible, "#3#BottomPagerRow.Visible"); // PagerSettings.Visible = false, PageCount = 2 grid = new PokerGridView (); grid.PagerSettings.Position = PagerPosition.TopAndBottom; grid.PagerSettings.Visible = false; grid.AllowPaging = true; grid.PageSize = 2; p.Form.Controls.Add (grid); grid.DataSource = new string [] { "A", "B", "C" }; grid.DataBind (); Assert.AreEqual (2, grid.PageCount, "#3#PageCount"); Assert.IsNull (grid.TopPagerRow, "#3#TopPagerRow"); Assert.IsNull (grid.BottomPagerRow, "#3#BottomPagerRow"); }
public void GridView_DataBind_NoDataSource () { PokerGridView g = new PokerGridView (); g.DataBind (); Assert.AreEqual (0, g.Rows.Count, "GridView_DataBind_NoDataSource"); }
public void GridView_DefaultProperties () { PokerGridView g = new PokerGridView (); Assert.AreEqual (0, g.StateBag.Count, "ViewState.Count"); Assert.AreEqual (false, g.AllowPaging, "AllowPaging"); Assert.AreEqual (false, g.AllowSorting, "AllowSorting"); // The AlternatingRowStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (true, g.AutoGenerateColumns, "AutoGenerateColumns"); Assert.AreEqual (false, g.AutoGenerateDeleteButton, "AutoGenerateDeleteButton"); Assert.AreEqual (false, g.AutoGenerateEditButton, "AutoGenerateEditButton"); Assert.AreEqual (false, g.AutoGenerateSelectButton, "AutoGenerateSelectButton"); Assert.AreEqual ("", g.BackImageUrl, "BackImageUrl"); Assert.AreEqual (null, g.BottomPagerRow, "BottomPagerRow"); Assert.AreEqual ("", g.Caption, "Caption"); Assert.AreEqual (TableCaptionAlign.NotSet, g.CaptionAlign, "CaptionAlign"); Assert.AreEqual (-1, g.CellPadding, "CellPadding"); Assert.AreEqual (0, g.CellSpacing, "CellSpacing"); // ToDo: The Columns property default value is tested by the DataControlFieldCollection and DataControlField tests Assert.AreEqual (0, g.DataKeyNames.Length, "DataKeyNames"); // ToDo: The DataKeys property default value is tested by the DataKeyArray and DataKey tests Assert.AreEqual (-1, g.EditIndex, "EditIndex"); // The EditRowStyle property is tested by the TableItemStyle test (already exists) // The EmptyDataRowStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (null, g.EmptyDataTemplate, "EmptyDataTemplate"); Assert.AreEqual ("", g.EmptyDataText, "EmptyDataText"); Assert.AreEqual (false, g.EnableSortingAndPagingCallbacks, "EnableSortingAndPagingCallbacks"); // The FooterStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (GridLines.Both, g.GridLines, "GridLines"); // The HeaderStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (HorizontalAlign.NotSet, g.HorizontalAlign, "HorizontalAlign"); Assert.AreEqual (0, g.PageIndex, "PageIndex"); // ToDo: The PagerSettings property is tested by the PagerSettings test // The PagerStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (null, g.PagerTemplate, "PagerTemplate"); Assert.AreEqual (10, g.PageSize, "PageSize"); Assert.AreEqual ("", g.RowHeaderColumn, "RowHeaderColumn"); // ToDo: The Rows property is tested by the GridViewRowCollection and GridViewRow test // The RowStyle property is tested by the TableItemStyle test (already exists) Assert.AreEqual (false, g.ShowFooter, "ShowFooter"); Assert.AreEqual (true, g.ShowHeader, "ShowHeader"); Assert.AreEqual (SortDirection.Ascending, g.SortDirection, "SortDirection"); Assert.AreEqual (null, g.TopPagerRow, "TopPagerRow"); Assert.AreEqual (true, g.UseAccessibleHeader, "UseAccessibleHeader"); }
public void GridView_Sort () { PokerGridView g = new PokerGridView (); Assert.AreEqual (false, sortingaction, "BeforeSorting"); g.Sorting += new GridViewSortEventHandler (Gridview_sorting); g.Sort("Item",SortDirection.Descending); Assert.AreEqual (true, sortingaction, "AfterSorting"); }
public void GridView_DefaultPropertiesNotWorking () { PokerGridView g = new PokerGridView (); Assert.AreEqual (null, g.FooterRow, "FooterRow"); Assert.AreEqual (null, g.HeaderRow, "HeaderRow"); Assert.AreEqual (true, g.Visible, "ViewVisible"); Assert.AreEqual (0, g.PageCount, "PageCount"); Assert.AreEqual ("", g.SortExpression, "SortExpression"); }
public void GridView_CreateChildControls () { PokerGridView g = new PokerGridView (); g.Page = new Page (); g.DataSource = myds; g.DataBind (); Assert.AreEqual(6,g.DoCreateChildControls(myds,true),"CreateChildControls#1"); g.AllowPaging = true; g.PageSize = 3; g.DataBind (); Assert.AreEqual (6, g.DoCreateChildControls (myds, true), "CreateChildControls#1"); }
public void GridView_Events () { PokerGridView gv = new PokerGridView (); gv.DataSource = myds; gv.DataBinding += new EventHandler (gv_DataBinding); gv.DataBound += new EventHandler (gv_DataBound); gv.PageIndexChanging += new GridViewPageEventHandler (gv_PageIndexChanging); gv.PageIndexChanged += new EventHandler (gv_PageIndexChanged); gv.PreRender += new EventHandler (gv_PreRender); gv.RowCancelingEdit += new GridViewCancelEditEventHandler (gv_RowCancelingEdit); gv.RowCommand += new GridViewCommandEventHandler (gv_RowCommand); gv.RowCreated += new GridViewRowEventHandler (gv_RowCreated); gv.RowDataBound += new GridViewRowEventHandler (gv_RowDataBound); gv.RowDeleted += new GridViewDeletedEventHandler(gv_RowDeleted); gv.RowDeleting+= new GridViewDeleteEventHandler(gv_RowDeleting); gv.RowEditing+=new GridViewEditEventHandler(gv_RowEditing); gv.RowUpdated+= new GridViewUpdatedEventHandler(gv_RowUpdated); gv.RowUpdating+=new GridViewUpdateEventHandler(gv_RowUpdating); gv.SelectedIndexChanged +=new EventHandler(gv_SelectedIndexChanged); gv.SelectedIndexChanging+=new GridViewSelectEventHandler(gv_SelectedIndexChanging); gv.Sorted +=new EventHandler(gv_Sorted); gv.Sorting +=new GridViewSortEventHandler(gv_Sorting); gv.Unload+=new EventHandler(gv_Unload); Assert.AreEqual (false, dataBinding, "BeforeDataBinding"); gv.DoOnDataBinding (new EventArgs ()); Assert.AreEqual (true, dataBinding, "AfterDataBinding"); Assert.AreEqual (false, dataBound, "BeforeDataBound"); gv.DoOnDataBound (new EventArgs ()); Assert.AreEqual (true, dataBound, "AfterDataBound"); Assert.AreEqual (false, pageIndexChanged, "BeforepageIndexChanged"); gv.DoOnPageIndexChanged (new EventArgs ()); Assert.AreEqual (true, pageIndexChanged, "AfterpageIndexChanged"); ResetEvents (); Assert.AreEqual (false, pageIndexChanging, "BeforepageIndexChanging"); gv.DoOnPageIndexChanging (new GridViewPageEventArgs(1)); Assert.AreEqual (true, pageIndexChanging, "AfterpageIndexChanging"); Assert.AreEqual (false, preRender, "BeforePreRender"); gv.DoOnPreRender (new EventArgs ()); Assert.AreEqual (true, preRender, "AfterPreRender"); ResetEvents (); Assert.AreEqual (false, gridViewCancelEdit, "BeforeGridViewCancelEdit"); gv.DoOnRowCancelingEdit (new GridViewCancelEditEventArgs (1)); Assert.AreEqual (true, gridViewCancelEdit, "AfterGridViewCancelEdit"); ResetEvents (); Assert.AreEqual (false, rowCommand, "BeforeRowCommand"); LinkButton lb= new LinkButton(); gv.DoOnRowCommand (new GridViewCommandEventArgs(lb,new CommandEventArgs("",null))); Assert.AreEqual (true, rowCommand, "AfterRowCommand"); Assert.AreEqual (false, rowCreated, "BeforeRowCreated"); gv.DoOnRowCreated (new GridViewRowEventArgs (gv.SelectedRow)); Assert.AreEqual (true, rowCommand, "AfterRowCreated"); Assert.AreEqual (false, rowDataBound, "BeforeRowDataBound"); gv.DoOnRowDataBound (new GridViewRowEventArgs (gv.SelectedRow)); Assert.AreEqual (true, rowDataBound, "AfterRowDataBound"); Assert.AreEqual (false, rowDeleted, "BeforeRowDeleted"); gv.DoOnRowDeleted(new GridViewDeletedEventArgs(1,new ArgumentException())); Assert.AreEqual (true, rowDeleted, "AfterRowDeleted"); ResetEvents (); Assert.AreEqual (false, rowDeleting, "BeforeRowDeleting"); gv.DoOnRowDeleting (new GridViewDeleteEventArgs (0)); Assert.AreEqual (true, rowDeleting, "AfterRowDeleting"); ResetEvents (); Assert.AreEqual (false, rowEditing, "BeforeRowEditing"); gv.DoOnRowEditing (new GridViewEditEventArgs (0)); Assert.AreEqual (true, rowEditing, "AfterRowEditing"); Assert.AreEqual (false, rowUpdated, "BeforeRowUpdated"); gv.DoOnRowUpdated (new GridViewUpdatedEventArgs(1,new Exception())); Assert.AreEqual (true, rowUpdated, "AfterRowUpdated"); ResetEvents (); Assert.AreEqual (false, rowUpdating, "BeforeRowUpdating"); gv.DoOnRowUpdating (new GridViewUpdateEventArgs (0)); Assert.AreEqual (true, rowUpdating, "AfterRowUpdating"); Assert.AreEqual (false, selectIndexChanged, "BeforeSelectedIndexChanged"); gv.DoOnSelectedIndexChanged (new EventArgs ()); Assert.AreEqual (true, selectIndexChanged, "AfterSelectedIndexChanged"); ResetEvents (); Assert.AreEqual (false, selectIndexChanging, "BeforeSelectedIndexChanging"); gv.DoOnSelectedIndexChanging (new GridViewSelectEventArgs (2)); Assert.AreEqual (true, selectIndexChanging, "AfterSelectedIndexChanging"); Assert.AreEqual (false, sorted, "BeforeSorted"); gv.DoOnSorted (new EventArgs ()); Assert.AreEqual (true, sorted, "AfterSorted"); Assert.AreEqual (false, sorting, "BeforeSorting"); gv.DoOnSorting(new GridViewSortEventArgs("",SortDirection.Ascending)); Assert.AreEqual (true, sorting, "AfterSorting"); Assert.AreEqual (false, unload, "BeforeUnload"); gv.DoOnUnload (new EventArgs ()); Assert.AreEqual (true, unload, "AfterUnload"); }