Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs
===================================================================
diff -u -rb326158bd228dc407858ba620a437a175baf0190 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision b326158bd228dc407858ba620a437a175baf0190)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -22,14 +22,18 @@
/// The from which to obtain information to render and bind actions
/// to the items of the . If null, this builder will not render items which
/// require this type of information.
+ /// The
+ /// from which to obtain information to render and bind actions to the items of the
+ /// . If null, this builder will not render items
+ /// which require this type of information.
/// The for which to create a .
/// Thrown when the required object instances could not be created based on
/// the or .
- public ContextMenuBuilder(IGuiCommandHandler commandHandler, TreeNode treeNode)
+ public ContextMenuBuilder(IGuiCommandHandler commandHandler, IExportImportCommandHandler importExportHandler, TreeNode treeNode)
{
try
{
- guiItemsFactory = new GuiContextMenuItemFactory(commandHandler, treeNode);
+ guiItemsFactory = new GuiContextMenuItemFactory(commandHandler, importExportHandler, treeNode);
treeViewItemsFactory = new TreeViewContextMenuItemFactory(treeNode);
}
catch (ArgumentNullException e)
Index: Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs
===================================================================
diff -u -rb326158bd228dc407858ba620a437a175baf0190 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision b326158bd228dc407858ba620a437a175baf0190)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -13,6 +13,7 @@
internal class GuiContextMenuItemFactory
{
private readonly IGuiCommandHandler commandHandler;
+ private readonly IExportImportCommandHandler exportImportCommandHandler;
private readonly TreeNode treeNode;
///
@@ -21,19 +22,27 @@
///
/// The which contains information for creating the
/// .
+ /// The
+ /// which contains information for creating the .
/// The for which to create .
- /// Thrown when is null.
- public GuiContextMenuItemFactory(IGuiCommandHandler commandHandler, TreeNode treeNode)
+ /// Thrown when either
+ /// or is null.
+ public GuiContextMenuItemFactory(IGuiCommandHandler commandHandler, IExportImportCommandHandler exportImportCommandHandler, TreeNode treeNode)
{
if (commandHandler == null)
{
throw new ArgumentNullException("commandHandler", Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui);
}
+ if (exportImportCommandHandler == null)
+ {
+ throw new ArgumentNullException("exportImportCommandHandler", Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_exportImport_handler);
+ }
if (treeNode == null)
{
throw new ArgumentNullException("treeNode", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node);
}
this.commandHandler = commandHandler;
+ this.exportImportCommandHandler = exportImportCommandHandler;
this.treeNode = treeNode;
}
@@ -65,14 +74,14 @@
public ToolStripItem CreateExportItem()
{
object dataObject = treeNode.Tag;
- bool canExport = commandHandler.CanExportFrom(dataObject);
+ bool canExport = exportImportCommandHandler.CanExportFrom(dataObject);
var newItem = new ToolStripMenuItem(Resources.Export)
{
ToolTipText = Resources.Export_ToolTip,
Image = Resources.ExportIcon,
Enabled = canExport
};
- newItem.Click += (s, e) => commandHandler.ExportFrom(dataObject);
+ newItem.Click += (s, e) => exportImportCommandHandler.ExportFrom(dataObject);
return newItem;
}
@@ -85,14 +94,14 @@
public ToolStripItem CreateImportItem()
{
object dataObject = treeNode.Tag;
- bool canImport = commandHandler.CanImportOn(dataObject);
+ bool canImport = exportImportCommandHandler.CanImportOn(dataObject);
var newItem = new ToolStripMenuItem(Resources.Import)
{
ToolTipText = Resources.Import_ToolTip,
Image = Resources.ImportIcon,
Enabled = canImport
};
- newItem.Click += (s, e) => commandHandler.ImportOn(dataObject);
+ newItem.Click += (s, e) => exportImportCommandHandler.ImportOn(dataObject);
return newItem;
}
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -rc0d27d013180f7c062deb22400091807cbab2445 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision c0d27d013180f7c062deb22400091807cbab2445)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -127,6 +127,7 @@
MessageWindowDialog.cs
+
Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs
===================================================================
diff -u -r8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d)
+++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -19,7 +19,7 @@
namespace Core.Common.Gui
{
- public class GuiCommandHandler : IGuiCommandHandler
+ public class GuiCommandHandler : IGuiCommandHandler, IExportImportCommandHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(GuiCommandHandler));
@@ -51,40 +51,11 @@
gui.Selection = obj;
}
- public bool CanImportOn(object obj)
- {
- return gui.ApplicationCore.GetSupportedFileImporters(obj).Any();
- }
-
- public bool CanExportFrom(object obj)
- {
- return gui.ApplicationCore.GetSupportedFileExporters(obj).Any();
- }
-
public bool CanShowPropertiesFor(object obj)
{
return gui.PropertyResolver.GetObjectProperties(obj) != null;
}
- public void ImportOn(object target, IFileImporter importer = null)
- {
- try
- {
- if (importer == null)
- {
- guiImportHandler.ImportDataTo(target);
- }
- else
- {
- guiImportHandler.ImportUsingImporter(importer, target);
- }
- }
- catch (Exception)
- {
- Log.ErrorFormat(Resources.GuiCommandHandler_ImportOn_Unable_to_import_on_0_, target);
- }
- }
-
public bool CanOpenSelectViewDialog()
{
return gui.Selection != null && gui.DocumentViewsResolver.GetViewInfosFor(gui.Selection).Count() > 1;
@@ -169,18 +140,6 @@
}
}
- public void ExportFrom(object data, IFileExporter exporter = null)
- {
- if (exporter == null)
- {
- guiExportHandler.ExportFrom(data);
- }
- else
- {
- guiExportHandler.GetExporterDialog(exporter, data);
- }
- }
-
///
/// Removes all document and tool views that are associated to the dataObject and/or its children.
///
@@ -204,6 +163,51 @@
gui.Project.NotifyObservers();
}
+ #region Implementation: IExportImportCommandHandler
+
+ public bool CanImportOn(object obj)
+ {
+ return gui.ApplicationCore.GetSupportedFileImporters(obj).Any();
+ }
+
+ public void ImportOn(object target, IFileImporter importer = null)
+ {
+ try
+ {
+ if (importer == null)
+ {
+ guiImportHandler.ImportDataTo(target);
+ }
+ else
+ {
+ guiImportHandler.ImportUsingImporter(importer, target);
+ }
+ }
+ catch (Exception)
+ {
+ Log.ErrorFormat(Resources.GuiCommandHandler_ImportOn_Unable_to_import_on_0_, target);
+ }
+ }
+
+ public bool CanExportFrom(object obj)
+ {
+ return gui.ApplicationCore.GetSupportedFileExporters(obj).Any();
+ }
+
+ public void ExportFrom(object data, IFileExporter exporter = null)
+ {
+ if (exporter == null)
+ {
+ guiExportHandler.ExportFrom(data);
+ }
+ else
+ {
+ guiExportHandler.GetExporterDialog(exporter, data);
+ }
+ }
+
+ #endregion
+
private GuiImportHandler CreateGuiImportHandler()
{
return new GuiImportHandler(gui);
Index: Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs
===================================================================
diff -u
--- Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs (revision 0)
+++ Core/Common/src/Core.Common.Gui/IExportImportCommandHandler.cs (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -0,0 +1,23 @@
+using Core.Common.Base.IO;
+
+namespace Core.Common.Gui
+{
+ public interface IExportImportCommandHandler
+ {
+ ///
+ /// Indicates if there are importers for the current Gui.Selection
+ ///
+ ///
+ bool CanImportOn(object obj);
+
+ ///
+ /// Indicates if there are exporters for the current Gui.Selection
+ ///
+ ///
+ bool CanExportFrom(object obj);
+
+ void ExportFrom(object data, IFileExporter exporter = null);
+
+ void ImportOn(object target, IFileImporter importer = null);
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs
===================================================================
diff -u -r8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision 8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d)
+++ Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Core.Common.Base.IO;
namespace Core.Common.Gui
{
@@ -50,18 +49,6 @@
void ShowPropertiesFor(object obj);
///
- /// Indicates if there are importers for the current Gui.Selection
- ///
- ///
- bool CanImportOn(object obj);
-
- ///
- /// Indicates if there are exporters for the current Gui.Selection
- ///
- ///
- bool CanExportFrom(object obj);
-
- ///
/// Indicates if there is a property view object for the current .
///
///
@@ -71,9 +58,5 @@
object GetDataOfActiveView();
void OpenLogFileExternal();
-
- void ExportFrom(object data, IFileExporter exporter = null);
-
- void ImportOn(object target, IFileImporter importer = null);
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs
===================================================================
diff -u -rf959ca1b291dc2a31bc7cf52990657b345548a95 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f959ca1b291dc2a31bc7cf52990657b345548a95)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
+// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -1211,6 +1211,16 @@
}
///
+ /// Looks up a localized string similar to Kan geen 'IExportImportCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'IExportImportCommandHandler'..
+ ///
+ public static string GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_exportImport_handler {
+ get {
+ return ResourceManager.GetString("GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_exportImp" +
+ "ort_handler", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Kan geen 'GuiCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'GuiCommandHandler'..
///
public static string GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui {
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx
===================================================================
diff -u -rf959ca1b291dc2a31bc7cf52990657b345548a95 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision f959ca1b291dc2a31bc7cf52990657b345548a95)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -955,4 +955,7 @@
Het Ringtoetsproject '{0}' is succesvol opgeslagen.
+
+ Kan geen 'IExportImportCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'IExportImportCommandHandler'.
+
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs
===================================================================
diff -u -r8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 8455cc72c8d0bc1b1dc0a0d3987b54c0ddcb292d)
+++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -276,7 +276,7 @@
public IContextMenuBuilder Get(TreeNode treeNode)
{
- return new ContextMenuBuilder(CommandHandler, treeNode);
+ return new ContextMenuBuilder(guiCommandHandler, guiCommandHandler, treeNode);
}
public IEnumerable GetAllDataWithViewDefinitionsRecursively(object rootDataObject)
Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs
===================================================================
diff -u -rb326158bd228dc407858ba620a437a175baf0190 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision b326158bd228dc407858ba620a437a175baf0190)
+++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -25,7 +25,7 @@
public void Constructor_NoTreeNode_ThrowsContextMenuBuilderException()
{
// Call
- TestDelegate test = () => new ContextMenuBuilder(null, null);
+ TestDelegate test = () => new ContextMenuBuilder(null, null, null);
// Assert
var message = Assert.Throws(test).Message;
@@ -37,30 +37,48 @@
{
// Setup
var treeNodeMock = mocks.StrictMock();
+ var importExportHandlerMock = mocks.StrictMock();
+ mocks.ReplayAll();
+ // Call
+ TestDelegate test = () => new ContextMenuBuilder(null, importExportHandlerMock, treeNodeMock);
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ Assert.AreEqual(Resources.ContextMenuBuilder_ContextMenuBuilder_Cannot_create_instances_of_factories, message);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_NoExportImportHandler_ThrowsContextMenuBuilderException()
+ {
+ // Setup
+ var treeNodeMock = mocks.StrictMock();
+ var guiCommandHandler = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(null, treeNodeMock);
+ TestDelegate test = () => new ContextMenuBuilder(guiCommandHandler, null, treeNodeMock);
// Assert
var message = Assert.Throws(test).Message;
Assert.AreEqual(Resources.ContextMenuBuilder_ContextMenuBuilder_Cannot_create_instances_of_factories, message);
mocks.VerifyAll();
- }
+ }
[Test]
public void Constructor_ParamsSet_DoesNotThrow()
{
// Setup
var guiCommandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
-
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(guiCommandHandlerMock, treeNodeMock);
+ TestDelegate test = () => new ContextMenuBuilder(guiCommandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Assert
Assert.DoesNotThrow(test);
@@ -73,11 +91,11 @@
{
// Setup
var guiCommandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
-
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(guiCommandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(guiCommandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.Build();
@@ -94,6 +112,8 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+
var treeNodePresenterMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
@@ -102,7 +122,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddRenameItem().Build();
@@ -121,6 +141,8 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+
var treeNodePresenterMock = mocks.StrictMock();
var treeParentNodeMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
@@ -135,7 +157,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddDeleteItem().Build();
@@ -156,6 +178,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
IList children = new List();
if (hasChildren)
@@ -166,7 +189,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddExpandAllItem().Build();
@@ -187,6 +210,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var treeNodeMock = mocks.StrictMock();
IList children = new List();
if (hasChildren)
@@ -197,7 +221,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddCollapseAllItem().Build();
@@ -218,6 +242,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var treeNodeMock = mocks.Stub();
var nodeData = new object();
@@ -227,7 +252,7 @@
treeNodeMock.Tag = nodeData;
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddOpenItem().Build();
@@ -248,15 +273,16 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var nodeData = new object();
var treeNodeMock = mocks.Stub();
- commandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
+ exportImportHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
mocks.ReplayAll();
treeNodeMock.Tag = nodeData;
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddExportItem().Build();
@@ -277,15 +303,16 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var nodeData = new object();
var treeNodeMock = mocks.Stub();
- commandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
+ exportImportHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
mocks.ReplayAll();
treeNodeMock.Tag = nodeData;
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddImportItem().Build();
@@ -306,6 +333,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
var nodeData = new object();
var treeNodeMock = mocks.Stub();
@@ -315,7 +343,7 @@
treeNodeMock.Tag = nodeData;
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddPropertiesItem().Build();
@@ -335,10 +363,10 @@
// Setup
var treeNodeMock = mocks.StrictMock();
var commandHandlerMock = mocks.StrictMock();
-
+ var exportImportHandlerMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
var item = new StrictContextMenuItem(null,null,null,null);
// Call
@@ -359,10 +387,10 @@
// Setup
var treeNodeMock = mocks.StrictMock();
var commandHandlerMock = mocks.StrictMock();
-
+ var exportImportHandlerMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
// Call
var result = builder.AddSeparator().Build();
@@ -382,10 +410,10 @@
// Setup
var treeNodeMock = mocks.StrictMock();
var commandHandlerMock = mocks.StrictMock();
-
+ var exportImportHandlerMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
var someItem = new StrictContextMenuItem(null, null, null, null);
@@ -413,10 +441,10 @@
// Setup
var treeNodeMock = mocks.StrictMock();
var commandHandlerMock = mocks.StrictMock();
-
+ var exportImportHandlerMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
var someItem = new StrictContextMenuItem(null, null, null, null);
var someOtherItem = new StrictContextMenuItem(null, null, null, null);
@@ -448,10 +476,10 @@
// Setup
var treeNodeMock = mocks.StrictMock();
var commandHandlerMock = mocks.StrictMock();
-
+ var exportImportHandlerMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(commandHandlerMock, treeNodeMock);
+ var builder = new ContextMenuBuilder(commandHandlerMock, exportImportHandlerMock, treeNodeMock);
builder.AddCustomItem(new StrictContextMenuItem(null, null, null, null));
Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs
===================================================================
diff -u -rb326158bd228dc407858ba620a437a175baf0190 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision b326158bd228dc407858ba620a437a175baf0190)
+++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -23,7 +23,7 @@
public void Constructor_WithoutCommandHandler_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => new GuiContextMenuItemFactory(null, null);
+ TestDelegate test = () => new GuiContextMenuItemFactory(null, null, null);
// Assert
var message = Assert.Throws(test).Message;
@@ -36,11 +36,11 @@
{
// Setup
var guiCommandHandlerMock = mocks.StrictMock();
-
+ var exportImportCommandHandler = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new GuiContextMenuItemFactory(guiCommandHandlerMock, null);
+ TestDelegate test = () => new GuiContextMenuItemFactory(guiCommandHandlerMock, exportImportCommandHandler, null);
// Assert
var message = Assert.Throws(test).Message;
@@ -51,16 +51,34 @@
}
[Test]
- public void Constructor_WithGuiAndTreeNode_DoesNotThrow()
+ public void Constructor_WithoutExportImportHandler_ThrowsArgumentNullException()
{
// Setup
var guiCommandHandlerMock = mocks.StrictMock();
- var treeNodeMock = mocks.Stub();
+ mocks.ReplayAll();
+ // Call
+ TestDelegate test = () => new GuiContextMenuItemFactory(guiCommandHandlerMock, null, null);
+
+ // Assert
+ var message = Assert.Throws(test).Message;
+ StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_exportImport_handler, message);
+ StringAssert.EndsWith("exportImportCommandHandler", message);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_WithAllInput_DoesNotThrow()
+ {
+ // Setup
+ var guiCommandHandlerMock = mocks.StrictMock();
+ var exportImportCommandHandlerMock = mocks.StrictMock();
+ var treeNodeMock = mocks.Stub();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new GuiContextMenuItemFactory(guiCommandHandlerMock, treeNodeMock);
+ TestDelegate test = () => new GuiContextMenuItemFactory(guiCommandHandlerMock, exportImportCommandHandlerMock, treeNodeMock);
// Assert
Assert.DoesNotThrow(test);
@@ -75,6 +93,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportCommandHandlerMock = mocks.StrictMock();
var nodeData = new object();
var nodeStub = mocks.Stub();
commandHandlerMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(hasViewersForNodeData);
@@ -87,7 +106,7 @@
nodeStub.Tag = nodeData;
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, nodeStub);
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, nodeStub);
// Call
var item = contextMenuFactory.CreateOpenItem();
@@ -109,19 +128,20 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportCommandHandlerMock = mocks.StrictMock();
var nodeData = new object();
var nodeStub = mocks.Stub();
- commandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
+ exportImportCommandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
if (hasExportersForNodeData)
{
- commandHandlerMock.Expect(ch => ch.ExportFrom(nodeData));
+ exportImportCommandHandlerMock.Expect(ch => ch.ExportFrom(nodeData));
}
mocks.ReplayAll();
nodeStub.Tag = nodeData;
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, nodeStub);
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, nodeStub);
// Call
var item = contextMenuFactory.CreateExportItem();
@@ -143,19 +163,20 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportCommandHandlerMock = mocks.StrictMock();
var nodeData = new object();
var nodeStub = mocks.Stub();
- commandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
+ exportImportCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
if (hasImportersForNodeData)
{
- commandHandlerMock.Expect(ch => ch.ImportOn(nodeData));
+ exportImportCommandHandlerMock.Expect(ch => ch.ImportOn(nodeData));
}
mocks.ReplayAll();
nodeStub.Tag = nodeData;
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, nodeStub);
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, nodeStub);
// Call
var item = contextMenuFactory.CreateImportItem();
@@ -177,6 +198,7 @@
{
// Setup
var commandHandlerMock = mocks.StrictMock();
+ var exportImportCommandHandlerMock = mocks.StrictMock();
var nodeData = new object();
var nodeStub = mocks.Stub();
commandHandlerMock.Expect(ch => ch.CanShowPropertiesFor(nodeData)).Return(hasPropertyInfoForNodeData);
@@ -185,7 +207,7 @@
commandHandlerMock.Expect(ch => ch.ShowPropertiesFor(nodeData));
}
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, nodeStub);
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, nodeStub);
mocks.ReplayAll();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationGroupContextNodePresenterTest.cs
===================================================================
diff -u -rcc608d648b3fe89d6f748f5245c532014186d578 -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationGroupContextNodePresenterTest.cs (.../PipingCalculationGroupContextNodePresenterTest.cs) (revision cc608d648b3fe89d6f748f5245c532014186d578)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationGroupContextNodePresenterTest.cs (.../PipingCalculationGroupContextNodePresenterTest.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -919,10 +919,10 @@
presenter.Expect(p => p.CanRenameNode(node)).Return(true);
var guiCommandHandler = mockRepository.Stub();
-
+ var exportImportHandler = mockRepository.Stub();
mockRepository.ReplayAll();
- var menuBuilder = new ContextMenuBuilder(guiCommandHandler, node);
+ var menuBuilder = new ContextMenuBuilder(guiCommandHandler, exportImportHandler, node);
var contextMenuBuilderProvider = new SimpleContextMenuBuilderProvider(menuBuilder);
var nodePresenter = new PipingCalculationGroupContextNodePresenter(contextMenuBuilderProvider);
@@ -1021,10 +1021,10 @@
node.Stub(n => n.Nodes).Return(new TreeNode[0]);
var guiCommandHandler = mockRepository.Stub();
-
+ var exportImportHandler = mockRepository.Stub();
mockRepository.ReplayAll();
- var menuBuilder = new ContextMenuBuilder(guiCommandHandler, node);
+ var menuBuilder = new ContextMenuBuilder(guiCommandHandler, exportImportHandler, node);
var contextMenuBuilderProvider = new SimpleContextMenuBuilderProvider(menuBuilder);
var nodePresenter = new PipingCalculationGroupContextNodePresenter(contextMenuBuilderProvider);
@@ -1119,10 +1119,10 @@
node.Stub(n => n.Nodes).Return(new TreeNode[0]);
var guiCommandHandler = mockRepository.Stub();
-
+ var exportImportHandler = mockRepository.Stub();
mockRepository.ReplayAll();
- var menuBuilder = new ContextMenuBuilder(guiCommandHandler, node);
+ var menuBuilder = new ContextMenuBuilder(guiCommandHandler, exportImportHandler, node);
var contextMenuBuilderProvider = new SimpleContextMenuBuilderProvider(menuBuilder);
var nodePresenter = new PipingCalculationGroupContextNodePresenter(contextMenuBuilderProvider);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs
===================================================================
diff -u -r2f45fd13d134ed6bdfcdb0967d07516beb30409c -rd0c45d1cb039e274f638638d5b3d6631c88c2228
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs (.../PipingFailureMechanismNodePresenterTest.cs) (revision 2f45fd13d134ed6bdfcdb0967d07516beb30409c)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs (.../PipingFailureMechanismNodePresenterTest.cs) (revision d0c45d1cb039e274f638638d5b3d6631c88c2228)
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
@@ -403,10 +402,10 @@
nodeMock.Tag = failureMechanism;
var commandHandler = mockRepository.Stub();
-
+ var exportImportHandler = mockRepository.Stub();
mockRepository.ReplayAll();
- var contextMenuBuilder = new ContextMenuBuilder(commandHandler, nodeMock);
+ var contextMenuBuilder = new ContextMenuBuilder(commandHandler, exportImportHandler, nodeMock);
var contextMenuBuilderProviderMock = new SimpleContextMenuBuilderProvider(contextMenuBuilder);
var nodePresenter = new PipingFailureMechanismNodePresenter(contextMenuBuilderProviderMock);