public void RemoveAllViewsForItem_GuiHasDocumentViews_CloseViewForDataAndChildren() { // Setup var data = new object(); var childData = new object(); var mocks = new MockRepository(); var documentViewsResolver = mocks.StrictMock <IDocumentViewController>(); documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(data)); documentViewsResolver.Expect(vr => vr.CloseAllViewsFor(childData)); var dataView = mocks.Stub <IView>(); dataView.Data = data; var childDataView = mocks.Stub <IView>(); childDataView.Data = childData; var viewsArray = new List <IView> { dataView, childDataView }; var viewHost = mocks.StrictMock <IViewHost>(); viewHost.Stub(ws => ws.DocumentViews).Return(viewsArray); var applicationSelection = mocks.Stub <IApplicationSelection>(); var pluginsHost = mocks.Stub <IPluginsHost>(); pluginsHost.Expect(g => g.GetAllDataWithViewDefinitionsRecursively(data)).Return(new[] { childData }); var viewController = mocks.Stub <IViewController>(); viewController.Stub(g => g.ViewHost).Return(viewHost); viewController.Stub(g => g.DocumentViewController).Return(documentViewsResolver); mocks.ReplayAll(); var viewCommandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call viewCommandHandler.RemoveAllViewsForItem(data); // Assert mocks.VerifyAll(); }
public void RemoveAllViewsForItem_DataObjectNull_DoNothing() { // Setup var mocks = new MockRepository(); var viewController = mocks.StrictMock <IViewController>(); var applicationSelection = mocks.StrictMock <IApplicationSelection>(); var pluginsHost = mocks.StrictMock <IPluginsHost>(); mocks.ReplayAll(); var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call commandHandler.RemoveAllViewsForItem(null); // Assert mocks.VerifyAll(); // Expect no calls on mocks }