예제 #1
0
        public void SetUp()
        {
            _currentHttpContext = HttpContextHelper.CreateHttpContext("GET", "default.html", null);
            HttpContextHelper.SetCurrent(_currentHttpContext);

            _page = new PageMock();
            _page.SetRequestValueCollection(new NameValueCollection());
            _currentHttpContext.Handler = _page;

            _parent            = new PlaceHolder();
            _parent.ID         = "Parent";
            _parent.Init      += new EventHandler(Control_Init);
            _parent.Load      += new EventHandler(Control_Load);
            _parent.PreRender += new EventHandler(Control_PreRender);
            _page.Controls.Add(_parent);

            _child            = new Literal();
            _child.ID         = "Child";
            _child.Init      += new EventHandler(Control_Init);
            _child.Load      += new EventHandler(Control_Load);
            _child.PreRender += new EventHandler(Control_PreRender);

            _parent.Controls.Add(_child);

            _invoker = new ControlInvoker(_parent);


            _pageAfterPostBack = new PageMock();
            _pageAfterPostBack.SetRequestValueCollection(new NameValueCollection());
            _currentHttpContext.Handler = _pageAfterPostBack;

            _parentAfterPostBack            = new PlaceHolder();
            _parentAfterPostBack.ID         = "Parent";
            _parentAfterPostBack.Init      += new EventHandler(Control_Init);
            _parentAfterPostBack.Load      += new EventHandler(Control_Load);
            _parentAfterPostBack.PreRender += new EventHandler(Control_PreRender);
            _pageAfterPostBack.Controls.Add(_parentAfterPostBack);

            _childAfterPostBack            = new Literal();
            _childAfterPostBack.ID         = "Child";
            _childAfterPostBack.Init      += new EventHandler(Control_Init);
            _childAfterPostBack.Load      += new EventHandler(Control_Load);
            _childAfterPostBack.PreRender += new EventHandler(Control_PreRender);

            _parentAfterPostBack.Controls.Add(_childAfterPostBack);

            _invokerAfterPostBack = new ControlInvoker(_parentAfterPostBack);

            _events = string.Empty;
        }
예제 #2
0
        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();
        }