Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Commands/ToggleProjectExplorerCommand.cs
===================================================================
diff -u -r78b15d3290c831ef1d7070aa1ccb48f57a15961f -re5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/Commands/ToggleProjectExplorerCommand.cs (.../ToggleProjectExplorerCommand.cs) (revision 78b15d3290c831ef1d7070aa1ccb48f57a15961f)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/Commands/ToggleProjectExplorerCommand.cs (.../ToggleProjectExplorerCommand.cs) (revision e5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Controls.Commands;
namespace Core.Plugins.ProjectExplorer.Commands
@@ -35,8 +36,13 @@
///
/// The to use for
/// querying and modifying the project explorer's state.
+ /// Throw when is null.
public ToggleProjectExplorerCommand(ProjectExplorerViewController viewController)
{
+ if (viewController == null)
+ {
+ throw new ArgumentNullException("viewController");
+ }
this.viewController = viewController;
}
Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs
===================================================================
diff -u -r78b15d3290c831ef1d7070aa1ccb48f57a15961f -re5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision 78b15d3290c831ef1d7070aa1ccb48f57a15961f)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision e5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132)
@@ -66,7 +66,7 @@
projectExplorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos);
projectExplorer.TreeView.TreeViewController.NodeUpdated += (s, e) => documentViewController.UpdateToolTips();
- toolViewController.ToolWindowViews.Add(projectExplorer, ViewLocation.Left | ViewLocation.Top);
+ toolViewController.OpenToolView(projectExplorer);
if (OnOpenView != null)
{
@@ -108,7 +108,7 @@
{
if (IsViewActive())
{
- toolViewController.ToolWindowViews.Remove(projectExplorer); // Disposes the view.
+ toolViewController.CloseToolView(projectExplorer); // Disposes the view.
projectExplorer = null;
}
}
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs
===================================================================
diff -u
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs (revision 0)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Commands/ToggleProjectExplorerCommandTest.cs (revision e5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132)
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Controls.Commands;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.Forms.ViewManager;
+using Core.Common.Gui.Selection;
+using Core.Plugins.ProjectExplorer.Commands;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Core.Plugins.ProjectExplorer.Test.Commands
+{
+ [TestFixture]
+ public class ToggleProjectExplorerCommandTest
+ {
+ [Test]
+ public void Constructor_WithoutController_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new ToggleProjectExplorerCommand(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Constructor_WithController_CreatesNewICommand()
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ var documentViewController = mocks.StrictMock();
+ var viewCommands = mocks.StrictMock();
+ var applicationSelection = mocks.StrictMock();
+ var toolViewController = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var treeNodeInfos = Enumerable.Empty();
+
+ var explorerViewController = new ProjectExplorerViewController(documentViewController, viewCommands, applicationSelection, toolViewController, treeNodeInfos);
+
+ // Call
+ var command = new ToggleProjectExplorerCommand(explorerViewController);
+
+ // Assert
+ Assert.IsInstanceOf(command);
+ Assert.IsTrue(command.Enabled);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Checked_Always_CallsViewControllerIsViewActive(bool isViewOpen)
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ var documentViewController = mocks.StrictMock();
+ var viewCommands = mocks.StrictMock();
+ var applicationSelection = mocks.StrictMock();
+ var toolViewController = mocks.StrictMock();
+ toolViewController.Expect(tvc => tvc.IsToolWindowOpen()).Return(isViewOpen);
+
+ mocks.ReplayAll();
+
+ var treeNodeInfos = Enumerable.Empty();
+
+ var explorerViewController = new ProjectExplorerViewController(documentViewController, viewCommands, applicationSelection, toolViewController, treeNodeInfos);
+
+ var command = new ToggleProjectExplorerCommand(explorerViewController);
+
+ // Call
+ var result = command.Checked;
+
+ // Assert
+ Assert.AreEqual(isViewOpen, result);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Execute_Always_CallsViewControllerToggleView(bool isViewOpen)
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ var documentViewController = mocks.StrictMock();
+ var viewCommands = mocks.StrictMock();
+ var applicationSelection = mocks.StrictMock();
+ var toolViewController = mocks.StrictMock();
+ toolViewController.Expect(tvc => tvc.IsToolWindowOpen()).Return(isViewOpen).Repeat.Twice();
+ if (isViewOpen)
+ {
+ toolViewController.Expect(tvc => tvc.CloseToolView(Arg.Matches(x => true)));
+ }
+ else
+ {
+ applicationSelection.Expect(a => a.SelectionChanged += null).IgnoreArguments();
+ toolViewController.Expect(tvc => tvc.OpenToolView(Arg.Matches(x => true)));
+ }
+
+ mocks.ReplayAll();
+
+ var treeNodeInfos = Enumerable.Empty();
+
+ var explorerViewController = new ProjectExplorerViewController(documentViewController, viewCommands, applicationSelection, toolViewController, treeNodeInfos);
+
+ var command = new ToggleProjectExplorerCommand(explorerViewController);
+
+ // Call
+ command.Execute();
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj
===================================================================
diff -u -r78b15d3290c831ef1d7070aa1ccb48f57a15961f -re5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision 78b15d3290c831ef1d7070aa1ccb48f57a15961f)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision e5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132)
@@ -95,6 +95,7 @@
+
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerGuiPluginTest.cs
===================================================================
diff -u -r83e8ea6f186faad530933f5620faa91f1920d1e1 -re5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerGuiPluginTest.cs (.../ProjectExplorerGuiPluginTest.cs) (revision 83e8ea6f186faad530933f5620faa91f1920d1e1)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerGuiPluginTest.cs (.../ProjectExplorerGuiPluginTest.cs) (revision e5b51f8c239f5bb4f4a3dce0399dbdd26ecc4132)
@@ -24,35 +24,25 @@
{
// Setup
var mocks = new MockRepository();
- var applicationCore = new ApplicationCore();
- var guiStub = mocks.Stub();
- var otherGuiPlugin = mocks.Stub();
+ var gui = mocks.StrictMock();
+ var otherGuiPlugin = mocks.StrictMock();
- guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub());
- guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub());
- guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub());
- guiStub.Stub(g => g.IsToolWindowOpen()).Return(false);
- guiStub.Expect(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty());
+ gui.Expect(g => g.ViewCommands).Return(mocks.Stub());
+ gui.Expect(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty());
- Expect.Call(guiStub.ApplicationCore).Return(applicationCore).Repeat.Any();
+ gui.Expect(g => g.IsToolWindowOpen()).Return(true).Repeat.Times(3);
+ gui.Expect(g => g.CloseToolView(Arg.Matches(r => true)));
- guiStub.Expect(g => g.SelectionChanged += Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.SelectionChanged -= Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.ProjectOpened += Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.ProjectOpened -= Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.ProjectClosing += Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.ProjectClosing -= Arg>.Is.Anything).Repeat.Any();
- guiStub.Expect(g => g.ToolWindowViews).Return(mocks.Stub()).Repeat.Any();
- guiStub.Expect(g => g.DocumentViews).Return(mocks.Stub()).Repeat.Any();
+ gui.Expect(g => g.ProjectOpened += Arg>.Is.Anything);
- guiStub.Replay();
+ gui.Replay();
using (var projectExplorerGuiPlugin = new ProjectExplorerGuiPlugin
{
- Gui = guiStub
+ Gui = gui
})
{
- guiStub.Expect(g => g.Plugins).Return(new List
+ gui.Expect(g => g.Plugins).Return(new List
{
projectExplorerGuiPlugin, otherGuiPlugin
}).Repeat.Any();