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"); }