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_PageIndex3 () { PokerDetailsView dv = new PokerDetailsView (); dv.AutoGenerateRows = false; dv.Fields.Add (new TemplateField ()); dv.Page = new Page (); dv.PageIndex = 10; dv.DefaultMode = DetailsViewMode.Insert; dv.SetRequiresDataBinding (true); Assert.AreEqual (0, dv.PageCount, "#0"); Assert.AreEqual (-1, dv.PageIndex, "#1"); dv.DataSource = myds; dv.DoEnsureDataBound (); Assert.AreEqual (0, dv.PageCount, "#2"); Assert.AreEqual (-1, dv.PageIndex, "#3"); dv.ChangeMode (DetailsViewMode.ReadOnly); Assert.AreEqual (0, dv.PageCount, "#4"); Assert.AreEqual (10, dv.PageIndex, "#5"); }