public static void DetailsView_RequiresDataBinding_LoadComplete (Page p) { PokerDetailsView view = new PokerDetailsView (); p.Form.Controls.Add (view); view.DataSource = new string [] { "A", "B", "C" }; view.DataBind (); Assert.AreEqual (false, view.GetRequiresDataBinding ()); view.PagerTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, view.GetRequiresDataBinding (), "PagerTemplate was set"); view.EmptyDataTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, view.GetRequiresDataBinding (), "EmptyDataTemplate was set"); view.HeaderTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, view.GetRequiresDataBinding (), "HeaderTemplate was set"); view.FooterTemplate = new CompiledTemplateBuilder (BuildTemplateMethod); Assert.AreEqual (false, view.GetRequiresDataBinding (), "FooterTemplate was set"); }
public void DetailsView_AssignToDefaultProperties () { PokerDetailsView dv = new PokerDetailsView (); dv.AllowPaging = true; dv.DataSource = myds; dv.DataBind (); Assert.AreEqual (true, dv.AllowPaging, "AllowPaging"); dv.AlternatingRowStyle.CssClass = "style.css"; Assert.AreEqual ("style.css", dv.AlternatingRowStyle.CssClass, "AlternatingRowStyle"); dv.AutoGenerateDeleteButton = true; Assert.AreEqual (true, dv.AutoGenerateDeleteButton, "AutoGenerateDeleteButton"); dv.AutoGenerateEditButton = true; Assert.AreEqual (true, dv.AutoGenerateEditButton, "AutoGenerateEditButton"); dv.AutoGenerateInsertButton = true; Assert.AreEqual (true, dv.AutoGenerateInsertButton, "AutoGenerateInsertButton"); dv.AutoGenerateRows = false; Assert.AreEqual (false, dv.AutoGenerateRows, "AutoGenerateRows"); dv.BackImageUrl = "image.jpg"; Assert.AreEqual ("image.jpg", dv.BackImageUrl, "BackImageUrl"); dv.Caption = "Caption Test"; Assert.AreEqual ("Caption Test", dv.Caption, "Caption"); dv.CaptionAlign = TableCaptionAlign.Right; Assert.AreEqual (TableCaptionAlign.Right, dv.CaptionAlign, "CaptionAlign"); dv.CellPadding = 2; Assert.AreEqual (2, dv.CellPadding, "CellPadding"); dv.CellSpacing = 5; Assert.AreEqual (5, dv.CellSpacing, "CellSpacing"); dv.CommandRowStyle.BackColor = Color.Purple; Assert.AreEqual (Color.Purple, dv.CommandRowStyle.BackColor, "CommandRowStyle.BackColor"); dv.ChangeMode (DetailsViewMode.Insert); Assert.AreEqual (DetailsViewMode.Insert, dv.CurrentMode, "CurrentModeInsert"); dv.ChangeMode (DetailsViewMode.Edit ); Assert.AreEqual (DetailsViewMode.Edit, dv.CurrentMode, "CurrentModeEdit"); Assert.AreEqual ("Item1", dv.DataItem, "DataItem"); Assert.AreEqual (6, dv.DataItemCount, "DataItemCount"); Assert.AreEqual (0, dv.DataItemIndex, "DataItemIndex"); string[] names ={ "test1", "test2", "test3" }; dv.DataKeyNames = names; Assert.AreEqual (names, dv.DataKeyNames, "DataKeyNames"); dv.DefaultMode = DetailsViewMode.Edit; Assert.AreEqual (DetailsViewMode.Edit, dv.DefaultMode, "DefaultModeEdit"); dv.DefaultMode = DetailsViewMode.Insert; Assert.AreEqual (DetailsViewMode.Insert, dv.DefaultMode, "DefaultModeInsert"); dv.DefaultMode = DetailsViewMode.ReadOnly; Assert.AreEqual (DetailsViewMode.ReadOnly, dv.DefaultMode, "DefaultModeReadOnly"); dv.EditRowStyle.ForeColor = Color.Pink; Assert.AreEqual (Color.Pink, dv.EditRowStyle.ForeColor, "EditRowStyle"); dv.EmptyDataRowStyle.HorizontalAlign = HorizontalAlign.Center; Assert.AreEqual (HorizontalAlign.Center, dv.EmptyDataRowStyle.HorizontalAlign, "HorizontalAlignCenter"); dv.EmptyDataTemplate = new DTemplate (); Assert.AreEqual (typeof (DTemplate), dv.EmptyDataTemplate.GetType() , "EmptyDataTemplate"); dv.EmptyDataText = "No Data"; Assert.AreEqual ("No Data", dv.EmptyDataText, "EmptyDataText"); dv.EnablePagingCallbacks = true; Assert.AreEqual (true, dv.EnablePagingCallbacks, "EnablePagingCallbacks"); dv.FieldHeaderStyle.CssClass = "style.css"; Assert.AreEqual ("style.css", dv.FieldHeaderStyle.CssClass, "FieldHeaderStyle"); DataControlFieldCollection coll=new DataControlFieldCollection (); dv.FooterStyle.HorizontalAlign = HorizontalAlign.Right ; Assert.AreEqual (HorizontalAlign.Right, dv.FooterStyle.HorizontalAlign , "FooterStyle"); dv.FooterTemplate = new DTemplate (); Assert.AreEqual (typeof(DTemplate ),dv.FooterTemplate.GetType() ,"FooterTemplate"); dv.FooterText = "Footer Text"; Assert.AreEqual ("Footer Text", dv.FooterText, "FooterText"); dv.GridLines = GridLines.Horizontal; Assert.AreEqual (GridLines.Horizontal, dv.GridLines, "GridLinesHorizontal "); dv.GridLines = GridLines.None; Assert.AreEqual (GridLines.None , dv.GridLines, "GridLinesNone "); dv.GridLines = GridLines.Vertical; Assert.AreEqual (GridLines.Vertical, dv.GridLines, "GridLinesVertical "); dv.GridLines = GridLines.Both; Assert.AreEqual (GridLines.Both, dv.GridLines, "GridLinesBoth "); dv.HeaderStyle.BorderColor = Color.PapayaWhip; Assert.AreEqual (Color.PapayaWhip, dv.HeaderStyle.BorderColor, "HeaderStyle"); dv.HeaderTemplate = new DTemplate (); Assert.AreEqual (typeof (DTemplate), dv.HeaderTemplate.GetType (), "HeaderTemplate"); dv.HeaderText = "Header Text"; Assert.AreEqual ("Header Text", dv.HeaderText, "HeaderText"); dv.HorizontalAlign = HorizontalAlign.Center; Assert.AreEqual (HorizontalAlign.Center, dv.HorizontalAlign, "HorizontalAlignCenter"); dv.HorizontalAlign = HorizontalAlign.Justify; Assert.AreEqual (HorizontalAlign.Justify , dv.HorizontalAlign, "HorizontalAlignJustify"); dv.HorizontalAlign = HorizontalAlign.Left ; Assert.AreEqual (HorizontalAlign.Left , dv.HorizontalAlign, "HorizontalAlignLeft"); dv.HorizontalAlign = HorizontalAlign.NotSet ; Assert.AreEqual (HorizontalAlign.NotSet , dv.HorizontalAlign, "HorizontalAlignNotSet"); dv.HorizontalAlign = HorizontalAlign.Right ; Assert.AreEqual (HorizontalAlign.Right , dv.HorizontalAlign, "HorizontalAlignRight"); dv.InsertRowStyle.BackColor = Color.PeachPuff; Assert.AreEqual (Color.PeachPuff, dv.InsertRowStyle.BackColor, "InsertRowStyle"); Assert.AreEqual (6, dv.PageCount, "PageCount"); Assert.AreEqual (0, dv.PageIndex, "PageIndex"); dv.PagerSettings.LastPageImageUrl = "image.jpg"; Assert.AreEqual ("image.jpg", dv.PagerSettings.LastPageImageUrl, "PagerSettings"); dv.PagerStyle.CssClass = "style.css"; Assert.AreEqual ("style.css", dv.PagerStyle.CssClass, "PagerStyle"); dv.PagerTemplate = new DTemplate (); Assert.AreEqual (typeof (DTemplate), dv.PagerTemplate.GetType (), "PagerTemplate"); Assert.AreEqual (1, dv.Rows.Count, "Rows"); dv.RowStyle.BackColor = Color.Plum ; Assert.AreEqual (Color.Plum, dv.RowStyle.BackColor, "RowStyle"); dv.FooterRow.CssClass="style.css"; Assert.AreEqual ("style.css", dv.FooterRow.CssClass , "FooterRow"); dv.HeaderRow.BackColor =Color.Pink ; Assert.AreEqual (Color.Pink, dv.HeaderRow.BackColor, "HeaderRow"); }
public void DetailsView_DataKey () { Page p = new Page (); PokerDetailsView fv = new PokerDetailsView (); p.Controls.Add (fv); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (TableObject).AssemblyQualifiedName; data.SelectMethod = "GetMyData"; p.Controls.Add (data); fv.DataSource = data; fv.DataKeyNames = new string [] { "ID", "FName" }; DataKey key1 = fv.DataKey; Assert.AreEqual (null, key1.Value, "DataKey.Value before binding"); Assert.AreEqual (0, key1.Values.Count, "DataKey.Values count before binding"); fv.DataBind (); DataKey key2 = fv.DataKey; DataKey key3 = fv.DataKey; Assert.IsFalse (Object.ReferenceEquals (key1, key2), "DataKey returns the same instans"); Assert.IsTrue (Object.ReferenceEquals (key2, key3), "DataKey returns the same instans"); Assert.AreEqual (1001, key1.Value, "DataKey.Value after binding"); Assert.AreEqual (2, key1.Values.Count, "DataKey.Values count after binding"); Assert.AreEqual (1001, key1.Values [0], "DataKey.Values[0] after binding"); Assert.AreEqual ("Mahesh", key1.Values [1], "DataKey.Values[1] after binding"); PokerDetailsView copy = new PokerDetailsView (); object state = fv.DoSaveControlState (); copy.DoLoadControlState (state); DataKey key4 = copy.DataKey; Assert.AreEqual (1001, key4.Value, "DataKey.Value from ControlState"); Assert.AreEqual (2, key4.Values.Count, "DataKey.Values count from ControlState"); Assert.AreEqual (1001, key4.Values [0], "DataKey.Values[0] from ControlState"); Assert.AreEqual ("Mahesh", key4.Values [1], "DataKey.Values[1] from ControlState"); }
public void DetailsView_CreateDataSourceSelectArguments () { DataSourceView view; Page p = new Page (); PokerDetailsView dv = new PokerDetailsView (); p.Controls.Add (dv); ObjectDataSource data = new ObjectDataSource (); data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.SortParameterName = "sortExpression"; DataSourceSelectArguments arg; p.Controls.Add (data); dv.DataSource = data; dv.DataBind (); arg = dv.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "Default"); dv.AllowPaging = true; dv.PageIndex = 2; arg = dv.DoCreateDataSourceSelectArguments (); view = dv.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 = dv.DoCreateDataSourceSelectArguments (); view = dv.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsFalse (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (new DataSourceSelectArguments (2, -1)), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = false"); dv.AllowPaging = false; arg = dv.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = false"); // make DataSourceView.CanRetrieveTotalRowCount = true data.SelectCountMethod = "GetCount"; arg = dv.DoCreateDataSourceSelectArguments (); Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = true"); dv.AllowPaging = true; arg = dv.DoCreateDataSourceSelectArguments (); DataSourceSelectArguments arg1 = new DataSourceSelectArguments (2, 1); arg1.RetrieveTotalRowCount = true; view = dv.DoGetData (); Assert.IsTrue (view.CanPage); Assert.IsTrue (view.CanRetrieveTotalRowCount); Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = true"); }
public static void DetailsView_DeleteItem (Page p) { LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerDetailsView dv = new PokerDetailsView (); ObjectDataSource ds = new ObjectDataSource (); ds.ID = "ObjectDataSource1"; ds.TypeName = "MonoTests.System.Web.UI.WebControls.TableObject"; ds.SelectMethod = "GetMyData"; ds.DeleteMethod = "Delete"; ds.InsertMethod = "Insert"; ds.UpdateMethod = "Update"; Parameter p1 = new Parameter ("ID", TypeCode.String); Parameter p2 = new Parameter ("FName", TypeCode.String); Parameter p3 = new Parameter ("LName", TypeCode.String); ds.DeleteParameters.Add (p1); ds.DeleteParameters.Add (p2); ds.DeleteParameters.Add (p3); dv.Page = p; ds.Page = p; p.Form.Controls.Add (lcb); p.Form.Controls.Add (dv); p.Form.Controls.Add (ds); p.Form.Controls.Add (lce); dv.AllowPaging = true; dv.DataKeyNames = new string[] { "ID", "FName", "LName" }; dv.DataSourceID = "ObjectDataSource1"; dv.DataBind (); dv.DeleteItem (); }
public void DetailsView_PageIndex4 () { PokerDetailsView dv = new PokerDetailsView (); dv.AllowPaging = true; dv.AutoGenerateRows = false; dv.Fields.Add (new TemplateField ()); dv.Page = new Page (); dv.PageIndex = 10; dv.DataSource = myds; dv.DataBind (); Assert.AreEqual (6, dv.PageCount, "#0"); Assert.AreEqual (5, dv.PageIndex, "#1"); }
public void DetailsView_InitializePager () { PokerDetailsView dv = new PokerDetailsView (); Page page = new Page (); dv.AllowPaging = true; dv.DataSource = myds; page.Controls.Add (dv); Assert.AreEqual (0, dv.PageCount, "BeforeInitializePagerPageCount"); Assert.AreEqual (false, dv.isInitializePager, "BeforeInitializePager"); dv.DataBind (); Assert.AreEqual (true, dv.isInitializePager, "AfterInitializePager"); Assert.AreEqual (6, dv.PageCount, "AfterInitializePagerPageCount"); }
public void FormView_DataBind () { PokerDetailsView dv = new PokerDetailsView (); dv.AllowPaging = true; dv.DataSource = myds; Assert.AreEqual (0, dv.PageCount, "BeforeDataBind1"); Assert.AreEqual (null, dv.DataItem, "BeforeDataBind2"); dv.DataBind (); Assert.AreEqual (6, dv.PageCount, "AfterDataBind1"); Assert.AreEqual (6, dv.DataItemCount, "AfterDataBind2"); Assert.AreEqual ("Item1", dv.DataItem, "AfterDataBind3"); }
public void DetailsView_CreateFieldSet_useDataSource () { DataTable ds = TableObject.CreateDataTable (); PokerDetailsView dv2 = new PokerDetailsView (); dv2.DataSource = ds; dv2.DataBind (); ICollection fieldSet2 = dv2.DoCreateFieldSet ("FieldTest", false); Assert.AreEqual (3, fieldSet2.Count, "FiledSetCount"); Assert.AreEqual ("ID", ((ArrayList) fieldSet2)[0].ToString (), "FieldValue1"); Assert.AreEqual (typeof (Int32), ((AutoGeneratedField) ((ArrayList) fieldSet2)[0]).DataType, "FieldType1"); Assert.AreEqual ("FName", ((ArrayList) fieldSet2)[1].ToString (), "FieldValue2"); Assert.AreEqual (typeof (String), ((AutoGeneratedField) ((ArrayList) fieldSet2)[1]).DataType, "FieldType2"); Assert.AreEqual ("LName", ((ArrayList) fieldSet2)[2].ToString (), "FieldValue3"); Assert.AreEqual (typeof (String), ((AutoGeneratedField) ((ArrayList) fieldSet2)[2]).DataType, "FieldType3"); }
public void DetailsView_GetCallBackResult () { PokerDetailsView dv = new PokerDetailsView (); Page p = new Page (); p.EnableEventValidation = false; p.Controls.Add (dv); DataTable ds = TableObject.CreateDataTable (); dv.AllowPaging = true; dv.EnablePagingCallbacks = true; dv.DataSource = ds; dv.DataBind (); dv.DoRaiseCallbackEvent ("1||0|"); string cbres = dv.DoGetCallbackResult (); Assert.IsNotNull (cbres); if (cbres.IndexOf ("1002") == -1) Assert.Fail ("Wrong item rendered fail"); }
public void DetailsView_CreateFieldSet_dont_useDataSource () { DataTable ds = TableObject.CreateDataTable (); PokerDetailsView dv1 = new PokerDetailsView (); dv1.DataSource = ds; dv1.DataBind (); ICollection fieldSet1 = dv1.DoCreateFieldSet ("FieldTest", true); Assert.AreEqual (1, fieldSet1.Count, "FiledSetCount"); AutoGeneratedField agf = (AutoGeneratedField) ((ArrayList) fieldSet1)[0]; Assert.AreEqual ("Item", agf.HeaderText, "FieldSetCount"); }
public void DetailsView_ExtractRowValues () { PokerDetailsView dv = new PokerDetailsView (); DataTable ds = TableObject.CreateDataTable (); dv.DataSource = ds; dv.DataBind (); OrderedDictionary fieldsValues = new OrderedDictionary (); dv.DoExtractRowValues (fieldsValues, true, true); Assert.AreEqual (3, fieldsValues.Count, "ExtractRowValues1"); Assert.AreEqual (3, fieldsValues.Keys.Count, "ExtractRowValues2"); Assert.AreEqual (3, fieldsValues.Values.Count, "ExtractRowValues3"); Assert.AreEqual (true, fieldsValues.Contains ("ID"), "ExtractRowValues4"); IDictionaryEnumerator enumerator=fieldsValues.GetEnumerator (); enumerator.MoveNext (); Assert.AreEqual ("ID",enumerator.Key,"FieldValue1"); Assert.AreEqual ("1001", enumerator.Value , "FieldValue2"); enumerator.MoveNext (); Assert.AreEqual ("FName", enumerator.Key, "FieldValue3"); Assert.AreEqual ("Mahesh", enumerator.Value, "FieldValue4"); enumerator.MoveNext (); Assert.AreEqual ("LName", enumerator.Key, "FieldValue5"); Assert.AreEqual ("Chand", enumerator.Value, "FieldValue6"); fieldsValues = new OrderedDictionary (); dv.DoExtractRowValues (fieldsValues, false, false); Assert.AreEqual (0, fieldsValues.Count, "ExtractRowValues-NotReadOnly1"); fieldsValues = new OrderedDictionary (); dv.DoExtractRowValues (fieldsValues, true, false); Assert.AreEqual (3, fieldsValues.Count, "ExtractRowValues-NoPrimaryKeys1"); Assert.AreEqual (3, fieldsValues.Keys.Count, "ExtractRowValues-NoPrimaryKeys2"); fieldsValues = new OrderedDictionary (); dv.DoExtractRowValues (fieldsValues, false, true); Assert.AreEqual (0, fieldsValues.Count, "ExtractRowValues-NotReadOnly2"); Assert.AreEqual (0, fieldsValues.Keys.Count, "ExtractRowValues-NotReadOnly3"); }
public void DetailsView_PageIndex5 () { PokerDetailsView dv = new PokerDetailsView (); dv.AutoGenerateRows = false; dv.Fields.Add (new TemplateField ()); dv.Page = new Page (); dv.PageIndex = 10; dv.DataSource = new MyEnumSource(6); dv.DataBind (); Assert.AreEqual (5, dv.PageIndex, "#1"); }
public static void DetailsView_EmptyContentRendering_Load(Page p) { LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerDetailsView dv = new PokerDetailsView (); dv.DataSource = new ArrayList (); dv.HeaderText = "Header Text"; dv.FooterText = "Footer Text"; LinkButton lb = new LinkButton (); lb.ID = "LinkButton1"; lb.Text = "Test"; p.Form.Controls.Add (lcb); p.Form.Controls.Add (dv); dv.DataBind (); p.Form.Controls.Add (lb); p.Form.Controls.Add (lce); }
public void DetailsView_PrepareControlHierarchy () { PokerDetailsView dv = new PokerDetailsView (); //dv.Render (); //Assert.AreEqual (0, dv.Controls.Count, "ControlHierarchy1"); //Assert.AreEqual (true, dv.controlHierarchy, "ControlHierarchy2"); dv.controlHierarchy = false; dv.AllowPaging = true; dv.DataSource = myds; dv.DataBind (); dv.Page = new Page (); dv.Render (); Assert.AreEqual (1, dv.Controls.Count, "ControlHierarchy3"); Assert.AreEqual (true, dv.controlHierarchy, "ControlHierarchy4"); Button bt = new Button (); dv.Page.EnableEventValidation = false; dv.Controls.Add (bt); dv.controlHierarchy = false; dv.Render (); Assert.AreEqual (2, dv.Controls.Count, "ControlHierarchy3"); Assert.AreEqual (true, dv.controlHierarchy, "ControlHierarchy4"); }
public static void DetailsView_EmptyDataTextProperty (Page p) { LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG); LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG); PokerDetailsView dv = new PokerDetailsView (); dv.DataSource = new ArrayList (); dv.EmptyDataText = "Empty Data"; LinkButton lb = new LinkButton (); lb.ID = "LinkButton1"; lb.Text = "Test"; p.Form.Controls.Add (lcb); p.Form.Controls.Add (dv); dv.DataBind (); p.Form.Controls.Add (lb); p.Form.Controls.Add (lce); }
public void DetailsView_BubbleEvents () { ResetEvents (); DetailsViewCommandEventArgs com; PokerDetailsView dv = new PokerDetailsView (); dv.DataSource = TableObject.CreateDataTable (); Page page = new Page (); Button bt = new Button (); dv.AllowPaging = true; dv.DataSource = myds; page.Controls.Add (dv); dv.DataBind (); dv.ItemCommand += new DetailsViewCommandEventHandler (dv_ItemCommand ); dv.ItemDeleted += new DetailsViewDeletedEventHandler (dv_ItemDeleted ); //Delete dv.ItemDeleting += new DetailsViewDeleteEventHandler (dv_ItemDeleting ); com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Delete", null)); Assert.AreEqual (false, itemCommand, "BeforeDeleteCommandBubbleEvent"); Assert.AreEqual (false, itemDeleting, "BeforeDeleteBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Delete"); Assert.AreEqual (true, itemDeleting, "AfterDeleteBubbleEvent"); Assert.AreEqual (true, itemCommand, "AfterDeleteCommandBubbleEvent"); //Insert itemCommand = false; dv.ItemInserting += new DetailsViewInsertEventHandler (dv_ItemInserting); dv.ChangeMode (DetailsViewMode.Insert); com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Insert", null)); Assert.AreEqual (false, itemCommand, "BeforeInsertCommandBubbleEvent"); Assert.AreEqual (false, itemInserting, "BeforeInsertBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Insert"); Assert.AreEqual (true, itemCommand, "AfterInsertCommandBubbleEvent"); Assert.AreEqual (true, itemInserting, "AfterInsertBubbleEvent"); //Update itemCommand = false; dv.ItemUpdating += new DetailsViewUpdateEventHandler (dv_ItemUpdating); dv.ChangeMode (DetailsViewMode.Edit); com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Update", null)); Assert.AreEqual (false, itemUpdating, "BeforeUpdateEvent"); Assert.AreEqual (false, itemCommand, "BeforeUpdateCommandEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Update"); Assert.AreEqual (true, itemCommand, "AfterUpdateCommandBubbleEvent"); Assert.AreEqual (true, itemUpdating, "AfterUpdateBubbleEvent"); //Cancel itemCommand = false; dv.ModeChanging += new DetailsViewModeEventHandler (dv_ModeChanging); com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Cancel", null)); Assert.AreEqual (false, itemCommand, "BeforeCancelCommandBubbleEvent"); Assert.AreEqual (false, modeChanging, "BeforeCancelBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Cancel"); Assert.AreEqual (true, itemCommand, "AfterCancelCommandBubbleEvent"); Assert.AreEqual (true, modeChanging, "AfterCancelBubbleEvent"); //Edit itemCommand = false; modeChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Edit", null)); Assert.AreEqual (false, itemCommand, "BeforeEditCommandBubbleEvent"); Assert.AreEqual (false, modeChanging, "BeforeEditBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Edit"); Assert.AreEqual (true, itemCommand, "AfterEditCommandBubbleEvent"); Assert.AreEqual (true, modeChanging, "AfterEditBubbleEvent"); //New itemCommand = false; modeChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("New", null)); Assert.AreEqual (false, itemCommand, "BeforeNewCommandBubbleEvent"); Assert.AreEqual (false, modeChanging, "BeforeNewBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - New"); Assert.AreEqual (true, itemCommand, "AfterNewCommandBubbleEvent"); Assert.AreEqual (true, modeChanging, "AfterNewBubbleEvent"); //Page Index default itemCommand = false; dv.PageIndexChanging += new DetailsViewPageEventHandler (dv_PageIndexChanging ); com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Page", null)); Assert.AreEqual (false, itemCommand, "BeforePageCommandBubbleEvent"); Assert.AreEqual (false, pageIndexChanging, "BeforePageBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Page Index default"); Assert.AreEqual (true, itemCommand, "AfterPageCommandBubbleEvent"); Assert.AreEqual (true, pageIndexChanging, "AfterPageBubbleEvent"); Assert.AreEqual (-1, newPageIndex, "PageIndex"); //Next Page itemCommand = false; pageIndexChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Page", "Next")); Assert.AreEqual (false, itemCommand, "BeforeNextPageCommandBubbleEvent"); Assert.AreEqual (false, pageIndexChanging, "BeforeNextPageBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Next Page"); Assert.AreEqual (true, itemCommand, "AfterNextPageCommandBubbleEvent"); Assert.AreEqual (true, pageIndexChanging, "AfterNextPageBubbleEvent"); Assert.AreEqual (1, newPageIndex, "NextPageIndex"); //Prev Page itemCommand = false; pageIndexChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Page", "Prev")); Assert.AreEqual (false, itemCommand, "BeforePrevPageCommandBubbleEvent"); Assert.AreEqual (false, pageIndexChanging, "BeforePrevPageBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Prev Page"); Assert.AreEqual (true, itemCommand, "AfterPrevPageCommandBubbleEvent"); Assert.AreEqual (true, pageIndexChanging, "AfterPrevPageBubbleEvent"); Assert.AreEqual (-1, newPageIndex, "PrevPageIndex"); //First Page itemCommand = false; pageIndexChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Page", "First")); Assert.AreEqual (false, itemCommand, "BeforeFirstPageCommandBubbleEvent"); Assert.AreEqual (false, pageIndexChanging, "BeforeFirstPageBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - First Page"); Assert.AreEqual (true, itemCommand, "AfterFirstPageCommandBubbleEvent"); Assert.AreEqual (true, pageIndexChanging, "AfterFirstPageBubbleEvent"); Assert.AreEqual (0, newPageIndex, "FirstPageIndex"); //Last Page itemCommand = false; pageIndexChanging = false; com = new DetailsViewCommandEventArgs (bt, new CommandEventArgs ("Page", "Last")); Assert.AreEqual (false, itemCommand, "BeforeLastPageCommandBubbleEvent"); Assert.AreEqual (false, pageIndexChanging, "BeforeLastPageBubbleEvent"); Assert.IsTrue (dv.DoOnBubbleEvent (bt, com), "OnBubbleEvent - Last Page"); Assert.AreEqual (true, itemCommand, "AfterLastPageCommandBubbleEvent"); Assert.AreEqual (true, pageIndexChanging, "AfterLastPageBubbleEvent"); Assert.AreEqual (5, newPageIndex, "FirstPageIndex"); }
public void DetailsView_DeleteItemHandler () { PokerDetailsView dv = new PokerDetailsView (); dv.DataSource = myds; dv.DataBind (); Assert.AreEqual (false, isDeleted, "BeforeDeleteItem"); dv.ItemDeleting += new DetailsViewDeleteEventHandler (dv_DeleteingHandler); dv.DeleteItem (); Assert.AreEqual (true, isDeleted, "BeforeDeleteItem"); }
public void DetailsView_PageCount () { Page p = new Page (); PokerDetailsView gv = new PokerDetailsView (); p.Controls.Add (gv); ObjectDataSource data = new ObjectDataSource (); data.ID = "ObjectDataSource1"; data.TypeName = typeof (TableObject).AssemblyQualifiedName; data.SelectMethod = "GetMyData"; p.Controls.Add (data); gv.DataSourceID = "ObjectDataSource1"; gv.DataKeyNames = new string [] { "ID", "FName" }; gv.SetRequiresDataBinding (true); Assert.AreEqual (0, gv.PageCount, "PageCount before binding"); gv.DataBind (); Assert.AreEqual (3, gv.PageCount, "PageCount after binding"); //PokerDetailsView copy = new PokerDetailsView (); //object state = gv.SaveState (); //copy.LoadState (state); //Assert.AreEqual (3, copy.PageCount, "PageCount from ViewState"); }
public void DetailsView_CreateAutoGeneratedRows () { PokerDetailsView dv = new PokerDetailsView (); DataTable ds = TableObject.CreateDataTable (); dv.DataSource = ds; dv.DataBind (); ICollection col = dv.DoCreateAutoGeneratedRows (dv.DataItem); Assert.AreEqual (typeof(ArrayList),col.GetType (),"CreateAutoGeneratedRowsType"); Assert.AreEqual (3, col.Count , "CreateAutoGeneratedRowsCount"); Assert.AreEqual (typeof (AutoGeneratedField), ((ArrayList) col)[0].GetType (), "AutoGeneratedRowType"); Assert.AreEqual ("ID", ((ArrayList) col)[0].ToString (), "AutoGeneratedRowName1"); Assert.AreEqual ("FName", ((AutoGeneratedField)((ArrayList) col)[1]).HeaderText, "AutoGeneratedRowName2"); Assert.AreEqual ("LName", ((AutoGeneratedField) ((ArrayList) col)[2]).SortExpression , "AutoGeneratedRowName3"); }
public void DetailsView_CreateChildControls2 () { PokerDetailsView dv = new PokerDetailsView (); dv.Page = new Page (); dv.DataSource = new MyEnumSource (20); dv.DataBind (); Assert.AreEqual (20, dv.PageCount, "CreateChildControls#0"); Assert.AreEqual (0, dv.DoCreateChildControls (null, true), "CreateChildControls#1"); Assert.AreEqual (0, dv.DoCreateChildControls (new MyEnumSource (0), true), "CreateChildControls#1"); Assert.AreEqual (20, dv.DoCreateChildControls (new MyEnumSource (20), true), "CreateChildControls#2"); Assert.AreEqual (0, dv.DoCreateChildControls (new object [0], false), "CreateChildControls#3"); Assert.AreEqual (5, dv.DoCreateChildControls (new object [5], false), "CreateChildControls#4"); }