protected override void SetUpPage() { base.SetUpPage(); _actualEvents = new StringCollection(); _lazyContainer = new LazyContainer(); _lazyContainer.ID = "LazyContainer"; _lazyContainer.Init += new EventHandler(LazyContainer_Init); _lazyContainer.Load += new EventHandler(LazyContainer_Load); NamingContainer.Controls.Add(_lazyContainer); _lazyContainerInvoker = new ControlInvoker(_lazyContainer); _parent = new ControlMock(); _parent.ID = "Parent"; _parent.Init += new EventHandler(Parent_Init); _parent.Load += new EventHandler(Parent_Load); _parentInvoker = new ControlInvoker(_parent); _child = new ControlMock(); _child.ID = "Child"; _child.Init += new EventHandler(Child_Init); _child.Load += new EventHandler(Child_Load); _childInvoker = new ControlInvoker(_child); _parent.Controls.Add(_child); _childSecond = new ControlMock(); _childSecond.ID = "ChildSecond"; _childSecond.Init += new EventHandler(ChildSecond_Init); _childSecond.Load += new EventHandler(ChildSecond_Load); _childSecondInvoker = new ControlInvoker(_childSecond); _parent.Controls.Add(_childSecond); }
public TestPageHolder(bool initializeState, RequestMode requestMode) { _page = new PageMock(); if (requestMode == RequestMode.PostBack) { _page.SetRequestValueCollection(new NameValueCollection()); } _otherNamingContainer = new NamingContainerMock(); _otherNamingContainer.ID = "OtherNamingContainer"; _page.Controls.Add(_otherNamingContainer); _otherControl = new ControlMock(); _otherControl.ID = "OtherControl"; _otherNamingContainer.Controls.Add(_otherControl); _namingContainer = new ReplaceableControlMock(); _namingContainer.ID = "NamingContainer"; _page.Controls.Add(_namingContainer); _parent = new ControlMock(); _parent.ID = "Parent"; _namingContainer.Controls.Add(_parent); _child = new ControlMock(); _child.ID = "Child"; _parent.Controls.Add(_child); _child2 = new Control(); _child2.ID = "Child2"; _parent.Controls.Add(_child2); _pageInvoker = new ControlInvoker(_page); if (initializeState) { _parent.ValueInViewState = "ParentValue"; _parent.ValueInControlState = "ParentValue"; _namingContainer.ValueInViewState = "NamingContainerValue"; _namingContainer.ValueInControlState = "NamingContainerValue"; _otherControl.ValueInViewState = "OtherValue"; _otherControl.ValueInControlState = "OtherValue"; } Page.RegisterViewStateHandler(); }
public void LoadViewState() { var testPageHolder = new TestPageHolder(false, RequestMode.PostBack); IStateModificationStrategy stateModificationStrategy = new StateClearingStrategy(); var replacer = new ControlReplacer(MemberCallerMock); replacer.StateModificationStrategy = stateModificationStrategy; testPageHolder.Page.Controls.Add(replacer); ControlInvoker replacerInvoker = new ControlInvoker(replacer); replacerInvoker.LoadViewStateRecursive(new Pair(null, new ArrayList { 0, new Pair("ChildState", null) })); stateModificationStrategy.LoadViewState(replacer, MemberCallerMock); var newControl = new ControlMock(); replacer.Controls.Add(newControl); Assert.That(newControl.ValueInViewState, Is.Null); }