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 void SetStatus(string status, params object[] args) { status = string.Format(status, args); Tracer.Verbose(status); ControlInvoker.Invoke(lblStatus, () => lblStatus.Text = status); }
protected virtual void SetUpPage() { _page = new PageMock(); _namingContainer = new NamingContainerMock(); _namingContainer.ID = "NamingContainer"; _page.Controls.Add(_namingContainer); _namingContainerInvoker = new ControlInvoker(_namingContainer); }
public void IsOptionsMenuVisibleWithoutWcagOverride() { ControlInvoker invoker = new ControlInvoker(_bocReferenceValue); invoker.InitRecursive(); WebConfigurationMock.Current = WebConfigurationFactory.GetLevelUndefined(); _bocReferenceValue.ShowOptionsMenu = true; _bocReferenceValue.OptionsMenuItems.Add(new WebMenuItem()); Assert.That(_bocReferenceValue.HasOptionsMenu, Is.True); }
private void WrightChat3(string text) { if (ChatTxtBox3.InvokeRequired) { var ci = new ControlInvoker(WrightChat3); this.BeginInvoke(ci, text); } else { ChatTxtBox3.Text = text; } }
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; }
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(); }
private string RenderControl(Control control) { var page = new Page(); page.Controls.Add(control); var ci = new ControlInvoker(page); ci.InitRecursive(); ci.LoadRecursive(); ci.PreRenderRecursive(); var stringWriter = new StringWriter(); control.RenderControl(new HtmlTextWriter(stringWriter)); return(stringWriter.ToString()); }
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); }
public virtual void SetUp() { _wcagHelperMock = new WcagHelperMock(); WcagHelper.SetInstance(_wcagHelperMock); _page = new Page(); _namingContainer = new NamingContainerMock(); _namingContainer.ID = "NamingContainer"; _page.Controls.Add(_namingContainer); _invoker = new ControlInvoker(_namingContainer); var context = HttpContextHelper.CreateHttpContext("GET", "/", ""); HttpContextHelper.SetCurrent(context); HttpBrowserCapabilities browser = new HttpBrowserCapabilities(); browser.Capabilities = new Hashtable(); browser.Capabilities.Add("browser", "IE"); browser.Capabilities.Add("majorversion", "7"); context.Request.Browser = browser; }
public override void SetUp() { base.SetUp(); _actualEvents = new StringCollection(); _values = new IBusinessObject[5]; _values[0] = (IBusinessObject)TypeWithAllDataTypes.Create("A", 1); _values[1] = (IBusinessObject)TypeWithAllDataTypes.Create("B", 2); _values[2] = (IBusinessObject)TypeWithAllDataTypes.Create("C", 3); _values[3] = (IBusinessObject)TypeWithAllDataTypes.Create("D", 4); _values[4] = (IBusinessObject)TypeWithAllDataTypes.Create("E", 5); _newValues = new IBusinessObject[2]; _newValues[0] = (IBusinessObject)TypeWithAllDataTypes.Create("F", 6); _newValues[1] = (IBusinessObject)TypeWithAllDataTypes.Create("G", 7); _class = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes)); _stringValuePath = BusinessObjectPropertyPath.CreateStatic(_class, "String"); _int32ValuePath = BusinessObjectPropertyPath.CreateStatic(_class, "Int32"); _stringValueSimpleColumn = new BocSimpleColumnDefinition(); _stringValueSimpleColumn.SetPropertyPath(_stringValuePath); _int32ValueSimpleColumn = new BocSimpleColumnDefinition(); _int32ValueSimpleColumn.SetPropertyPath(_int32ValuePath); _columns = new BocColumnDefinition[2]; _columns[0] = _stringValueSimpleColumn; _columns[1] = _int32ValueSimpleColumn; _editModeHost = new FakeEditModeHost(); _editModeHost.ID = "BocList"; _controller = new EditModeController(_editModeHost); _controller.ID = "Controller"; NamingContainer.Controls.Add(_controller); _controllerInvoker = new ControlInvoker(_controller); _editModeHost.NotifyOnEditableRowChangesCanceled = (i, o) => _actualEvents.Add(FormatChangesCanceledEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesCanceling = (i, o) => _actualEvents.Add(FormatChangesCancelingEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesSaved = (i, o) => _actualEvents.Add(FormatChangesSavedEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesSaving = (i, o) => _actualEvents.Add(FormatChangesSavingEventMessage(i, o)); _editModeHost.NotifyAddRows = objects => { var oldLength = _editModeHost.Value.Count; _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Concat(objects).ToArray(); return(((IBusinessObject[])_editModeHost.Value).Select((o, i) => new BocListRow(i, o)).Skip(oldLength).ToArray()); }; _editModeHost.NotifyRemoveRows = objects => { var removedRows = ((IBusinessObject[])_editModeHost.Value) .Select((o, i) => new BocListRow(i, o)) .Where(r => objects.Contains(r.BusinessObject)) .ToArray(); _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Except(objects).ToArray(); return(removedRows); }; _editModeHost.NotifyEndRowEditModeCleanUp = i => _actualEvents.Add(FormatEndRowEditModeCleanUp(i)); _editModeHost.NotifyEndListEditModeCleanUp = () => _actualEvents.Add(FormatEndListEditModeCleanUp()); _editModeHost.NotifyValidateEditableRows = () => _actualEvents.Add(FormatValidateEditableRows()); _editModeHost.Value = _values; _editModeHost.RowIDProvider = new FakeRowIDProvider(); _editModeHost.EditModeControlFactory = EditableRowControlFactory.CreateEditableRowControlFactory(); _editModeHost.EditModeDataSourceFactory = new EditableRowDataSourceFactory(); _editModeHost.EnableEditModeValidator = true; _editModeHost.AreCustomCellsValid = true; }