public IContentPart FindPart(string partId) { if (partId == this.Id) { return(this); } foreach (IContentPart p in this.Parts) { if (p.Id == partId) { return(p); } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; IContentPart result = container.FindPart(partId); if (result != null) { return(result); } } } return(null); }
public bool RemovePart(string id) { if (id == this.Id) { return(false); } IContentPart toRemove = null; foreach (IContentPart p in this.Parts) { if (p.Id == id) { toRemove = p; break; } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; bool result = container.RemovePart(id); if (result) { return(result); } } } if (toRemove != null) { this.Parts.Remove(toRemove); } return(true); }
public bool RemovePart(string partId) { foreach (Column c in this._Columns) { IContentPart toRemove = null; foreach (IContentPart p in c.Parts) { if (p.Id == partId) { toRemove = p; break; } if (p is IColumnContainer) { IColumnContainer container = p as IColumnContainer; bool result = container.RemovePart(partId); if (result) { return(true); } } } if (toRemove != null) { c.Parts.Remove(toRemove); return(true); } } return(false); }
public void Show_Property_Grid_Called() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); //panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); }
protected override void RemoveItemInternal(IColumn obj) { IColumnContainer container = itemContainer as IColumnContainer; if (container != null) { container.RemoveColumn(obj); } else { throw new InvalidOperationException("No Entity attached to ColumnCollectionPresenter"); } }
protected override IColumn AddItemInternal() { IColumnContainer container = itemContainer as IColumnContainer; if (container != null) { var column = new Column("NewColumn"); container.AddColumn(column); return(column); } throw new InvalidOperationException("No Entity attached to ColumnCollectionPresenter"); }
protected override void SetItemsOnForm() { form.Clear(); IColumnContainer container = itemContainer as IColumnContainer; if (container != null) { form.Items = container.Columns; } else { throw new InvalidOperationException("No Entity attached to ColumnCollectionPresenter"); } }
private void ProcessColumnsNode(IColumnContainer parent, XmlNode columnsNode) { // ReSharper disable PossibleNullReferenceException if (columnsNode == null) { return; } foreach (XmlNode columnNode in columnsNode.SelectNodes("Column")) { IColumn column = ProcessColumnNode(columnNode); parent.AddColumn(column); } // ReSharper restore PossibleNullReferenceException }
public void Exception_Thrown_If_Selected_Column_Is_Null() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = (ItemCollectionPresenter<IColumn>) new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); form.Stub(f => f.SelectedItem).Return(null); var raiser = form.GetEventRaiser(f => f.RemoveItem += null); raiser.Raise(form, new EventArgs()); }
public void Property_Changed_Registered() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = (ItemCollectionPresenter<IColumn>) new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments()); Assert.That(presenter.Detached, Is.False); presenter.DetachFromModel(); Assert.That(presenter.Detached, Is.True); obj.AssertWasCalled(o => o.PropertyChanged -= null, c => c.IgnoreArguments()); }
public void Re_Attaching_First_Detaches() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = (ItemCollectionPresenter<IColumn>) new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments()); //Assert.That(presenter.Detached, Is.False); //presenter.AttachToModel(obj); //Assert.That(presenter.Detached, Is.False); obj.AssertWasCalled(o => o.PropertyChanged -= null, c => c.IgnoreArguments()); obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments().Repeat.Twice()); }
public void Column_Removed_Correctly() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = (ItemCollectionPresenter<IColumn>) new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); IColumn selectedColumn = new Column("Column1"); form.Stub(f => f.SelectedItem).Return(selectedColumn); var raiser = form.GetEventRaiser(f => f.RemoveItem += null); raiser.Raise(form, new EventArgs()); obj.AssertWasCalled(o => o.RemoveColumn(selectedColumn)); }
public void New_Column_Added_Correctly() { ICollectionForm <IColumn> form = MockRepository.GenerateMock <ICollectionForm <IColumn> >(); IColumnContainer obj = MockRepository.GenerateMock <IColumnContainer>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //var presenter = new ColumnCollectionPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); var raiser = form.GetEventRaiser(f => f.AddItem += null); raiser.Raise(form, new EventArgs()); panel.AssertWasCalled(p => p.ShowObjectPropertyGrid(Arg <Column> .Matches(c => c != null && c.Name == "NewColumn"))); //panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); form.AssertWasCalled(f => f.Clear()); obj.AssertWasCalled(o => o.AddColumn(Arg <Column> .Matches(c => c != null && c.Name == "NewColumn"))); }
internal ListViewColumnCollection(IColumnContainer parent) { this.parent = parent; }
private void ProcessColumnsNode(IColumnContainer parent, XmlNode columnsNode) { // ReSharper disable PossibleNullReferenceException if (columnsNode == null) return; foreach (XmlNode columnNode in columnsNode.SelectNodes("Column")) { IColumn column = ProcessColumnNode(columnNode); parent.AddColumn(column); } // ReSharper restore PossibleNullReferenceException }