public void SaveViewState () { DataGridPoker p = new DataGridPoker (); p.TrackState (); object [] vs = (object []) p.SaveState (); Assert.AreEqual (vs.Length, 11, "A1"); // By default the viewstate is all null for (int i = 0; i < vs.Length; i++) Assert.IsNull (vs [i], "A2-" + i); // // TODO: What goes in the [1] and [9] slots? // p.AllowPaging = true; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [0], "A3"); /* This test doesn't work right now. It must be an issue in the DataGridPagerStyle p.PagerStyle.Visible = true; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [2], "A5"); */ p.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [3], "A6"); p.FooterStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [4], "A7"); p.ItemStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [5], "A8"); p.AlternatingItemStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [6], "A9"); p.SelectedItemStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [7], "A10"); p.EditItemStyle.HorizontalAlign = HorizontalAlign.Center; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [8], "A11"); PagedDataSource source = new PagedDataSource (); DataTable table = new DataTable (); ArrayList columns; table.Columns.Add (new DataColumn ("one", typeof (string))); table.Columns.Add (new DataColumn ("two", typeof (string))); table.Columns.Add (new DataColumn ("three", typeof (string))); source.DataSource = new DataView (table); columns = p.CreateColumns (source, true); vs = (object []) p.SaveState (); Assert.IsNull (vs [9], "A12"); p.BackImageUrl = "foobar url"; vs = (object []) p.SaveState (); Assert.IsNotNull (vs [9], "A12"); Assert.IsNotNull (vs [10], "A12"); Assert.AreEqual (vs [10].GetType (), typeof (object []), "A12"); object [] cols = (object []) vs [10]; Assert.AreEqual (cols.Length, 3, "A13"); }