public void ListView_EnsureLayoutTemplate() { var events = new EventRecorder(); var lvp = new ListViewPoker(events); lvp.DoEnsureLayoutTemplate(); Assert.AreEqual(2, events.Count, "#A1"); Assert.AreEqual("OnLayoutCreated:Enter", events [0], "#A2"); Assert.AreEqual("OnLayoutCreated:Leave", events [1], "#A3"); Assert.AreEqual(0, lvp.Controls.Count, "#A4"); events.Clear(); lvp.LayoutTemplate = new TestTemplate(); lvp.DoEnsureLayoutTemplate(); Assert.AreEqual(2, events.Count, "#B1"); Assert.AreEqual("OnLayoutCreated:Enter", events [0], "#B2"); Assert.AreEqual("OnLayoutCreated:Leave", events [1], "#B3"); Assert.AreEqual(1, lvp.Controls.Count, "#B4"); Assert.AreEqual(typeof(Control), lvp.Controls [0].GetType(), "#B5"); Assert.AreEqual("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#B6"); events.Clear(); lvp.DoEnsureLayoutTemplate(); Assert.AreEqual(0, events.Count, "#C1"); Assert.AreEqual(1, lvp.Controls.Count, "#C2"); Assert.AreEqual(typeof(Control), lvp.Controls [0].GetType(), "#C3"); Assert.AreEqual("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#C4"); }
public void DataPagerFieldCollection_Events() { var events = new EventRecorder(); var coll = new DataPagerFieldCollectionPoker(new DataPager(), events); coll.CatchFieldsChangedEvent(); coll.Insert(0, new NextPreviousPagerField()); Assert.AreEqual(6, events.Count); Assert.AreEqual("OnValidate:Enter", events [0], "#A1"); Assert.AreEqual("OnValidate:Leave", events [1], "#A2"); Assert.AreEqual("OnInsertComplete:Enter", events [2], "#A3"); Assert.AreEqual("OnFieldsChanged:Enter", events [3], "#A4"); Assert.AreEqual("OnFieldsChanged:Leave", events [4], "#A5"); Assert.AreEqual("OnInsertComplete:Leave", events [5], "#A6"); events.Clear(); coll.Clear(); Assert.AreEqual(4, events.Count); Assert.AreEqual("OnClearComplete:Enter", events [0], "#B1"); Assert.AreEqual("OnFieldsChanged:Enter", events [1], "#B2"); Assert.AreEqual("OnFieldsChanged:Leave", events [2], "#B3"); Assert.AreEqual("OnClearComplete:Leave", events [3], "#B4"); NextPreviousPagerField field = new NextPreviousPagerField(); coll.Insert(0, field); events.Clear(); coll.Remove(field); Assert.AreEqual(8, events.Count); Assert.AreEqual("OnValidate:Enter", events [0], "#C1"); Assert.AreEqual("OnValidate:Leave", events [1], "#C2"); Assert.AreEqual("OnValidate:Enter", events [2], "#C3"); Assert.AreEqual("OnValidate:Leave", events [3], "#C4"); Assert.AreEqual("OnRemoveComplete:Enter", events [4], "#C5"); Assert.AreEqual("OnFieldsChanged:Enter", events [5], "#C6"); Assert.AreEqual("OnFieldsChanged:Leave", events [6], "#C7"); Assert.AreEqual("OnRemoveComplete:Leave", events [7], "#C8"); coll.Insert(0, field); events.Clear(); coll.RemoveAt(0); Assert.AreEqual(4, events.Count); Assert.AreEqual("OnRemoveComplete:Enter", events [0], "#D1"); Assert.AreEqual("OnFieldsChanged:Enter", events [1], "#D2"); Assert.AreEqual("OnFieldsChanged:Leave", events [2], "#D3"); Assert.AreEqual("OnRemoveComplete:Leave", events [3], "#D4"); }
public void ListView_SetPageProperties_Events() { var events = new EventRecorder(); var lvp = new ListViewPoker(events); // No events expected: databind is false events.Clear(); lvp.DoSetPageProperties(0, 1, false); // No events expected: startRowIndex and maximumRows don't change values events.Clear(); lvp.DoSetPageProperties(0, 1, true); Assert.AreEqual(0, events.Count, "#A1"); // No events expected: startRowIndex changes, but databind is false events.Clear(); lvp.DoSetPageProperties(1, 1, false); Assert.AreEqual(0, events.Count, "#A2"); // No events expected: maximumRows changes, but databind is false events.Clear(); lvp.DoSetPageProperties(1, 2, false); Assert.AreEqual(0, events.Count, "#A3"); // No events expected: maximumRows and startRowIndex change but databind is // false events.Clear(); lvp.DoSetPageProperties(3, 4, false); Assert.AreEqual(0, events.Count, "#A4"); // Events expected: maximumRows and startRowIndex change and databind is // true events.Clear(); lvp.DoSetPageProperties(5, 6, true); Assert.AreEqual(4, events.Count, "#A5"); Assert.AreEqual("OnPagePropertiesChanging:Enter", events [0], "#A6"); Assert.AreEqual("OnPagePropertiesChanging:Leave", events [1], "#A7"); Assert.AreEqual("OnPagePropertiesChanged:Enter", events [2], "#A8"); Assert.AreEqual("OnPagePropertiesChanged:Leave", events [3], "#A9"); // Events expected: maximumRows changes and databind is true events.Clear(); lvp.DoSetPageProperties(5, 7, true); Assert.AreEqual(4, events.Count, "#A10"); Assert.AreEqual("OnPagePropertiesChanging:Enter", events [0], "#A11"); Assert.AreEqual("OnPagePropertiesChanging:Leave", events [1], "#A12"); Assert.AreEqual("OnPagePropertiesChanged:Enter", events [2], "#A13"); Assert.AreEqual("OnPagePropertiesChanged:Leave", events [3], "#A14"); // Events expected: startRowIndex changes and databind is true events.Clear(); lvp.DoSetPageProperties(6, 7, true); Assert.AreEqual(4, events.Count, "#A15"); Assert.AreEqual("OnPagePropertiesChanging:Enter", events [0], "#A16"); Assert.AreEqual("OnPagePropertiesChanging:Leave", events [1], "#A17"); Assert.AreEqual("OnPagePropertiesChanged:Enter", events [2], "#A18"); Assert.AreEqual("OnPagePropertiesChanged:Leave", events [3], "#A19"); }