Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs =================================================================== diff -u -reb7f8fe1e85f00faf16a1cddef014728d60a2b19 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision eb7f8fe1e85f00faf16a1cddef014728d60a2b19) +++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -16,19 +16,19 @@ private readonly ContextMenuStrip contextMenu; /// - /// Creates a new instance of , which uses the given to + /// Creates a new instance of , which uses the given to /// create a for the given . /// - /// The from which to obtain information to render and bind actions + /// 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 is null. - public ContextMenuBuilder(IGui gui, ITreeNode treeNode) + public ContextMenuBuilder(IGuiCommandHandler commandHandler, ITreeNode treeNode) { - if (gui != null) + if (commandHandler != null) { - guiItemsFactory = new GuiContextMenuItemFactory(gui, treeNode); + guiItemsFactory = new GuiContextMenuItemFactory(commandHandler); } treeViewItemsFactory = new TreeViewContextMenuItemFactory(treeNode); contextMenu = new ContextMenuStrip(); Index: Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs =================================================================== diff -u -re6e92cb42b1e4983add2406300958b6b116ba781 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision e6e92cb42b1e4983add2406300958b6b116ba781) +++ Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Windows.Forms; using Core.Common.Controls; using Core.Common.Gui.Properties; @@ -13,32 +12,22 @@ /// internal class GuiContextMenuItemFactory { - private readonly IGui gui; - private readonly ITreeNode treeNode; + private readonly IGuiCommandHandler commandHandler; /// - /// Creates a new instance of , which uses the to create - /// . + /// Creates a new instance of , which uses the + /// to create . /// - /// The which contains information for creating the . - /// The for which to create . - /// Thrown when - /// - /// is null - /// is null - /// - public GuiContextMenuItemFactory(IGui gui, ITreeNode treeNode) + /// The which contains information for creating the + /// . + /// Thrown when is null. + public GuiContextMenuItemFactory(IGuiCommandHandler commandHandler) { - if (gui == null) + if (commandHandler == null) { - throw new ArgumentNullException("gui", Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui); + throw new ArgumentNullException("commandHandler", Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui); } - if (treeNode == null) - { - throw new ArgumentNullException("treeNode", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node); - } - this.treeNode = treeNode; - this.gui = gui; + this.commandHandler = commandHandler; } /// @@ -48,14 +37,14 @@ /// The created . public ToolStripItem CreateOpenItem() { - var data = treeNode.Tag; - var viewers = gui.Plugins.SelectMany(p => p.GetViewInfoObjects()).Where(pi => pi.DataType == data.GetType()); ; + bool canOpenView = commandHandler.CanOpenDefaultViewForSelection(); var newItem = new ToolStripMenuItem(Resources.Open) { ToolTipText = Resources.Open_ToolTip, Image = Resources.OpenIcon, - Enabled = viewers.Any() + Enabled = canOpenView }; + newItem.Click += (s, e) => commandHandler.OpenDefaultViewForSelection(); return newItem; } @@ -67,14 +56,14 @@ /// The created . public ToolStripItem CreateExportItem() { - var data = treeNode.Tag; - var exporters = gui.ApplicationCore.GetSupportedFileExporters(data); + bool canExport = commandHandler.CanExportFromGuiSelection(); var newItem = new ToolStripMenuItem(Resources.Export) { ToolTipText = Resources.Export_ToolTip, Image = Resources.ExportIcon, - Enabled = exporters.Any() + Enabled = canExport }; + newItem.Click += (s, e) => commandHandler.ExportSelectedItem(); return newItem; } @@ -86,14 +75,14 @@ /// The created . public ToolStripItem CreateImportItem() { - var data = treeNode.Tag; - var importers = gui.ApplicationCore.GetSupportedFileImporters(data); + bool canImport = commandHandler.CanImportToGuiSelection(); var newItem = new ToolStripMenuItem(Resources.Import) { ToolTipText = Resources.Import_ToolTip, Image = Resources.ImportIcon, - Enabled = importers.Any() + Enabled = canImport }; + newItem.Click += (s,e) => commandHandler.ImportToGuiSelection(); return newItem; } @@ -105,21 +94,15 @@ /// The created . public ToolStripItem CreatePropertiesItem() { - var data = treeNode.Tag; - var propertyInfos = gui.Plugins.SelectMany(p => p.GetPropertyInfos()).Where(pi => pi.ObjectType == data.GetType()); + bool canShowProperties = commandHandler.CanShowPropertiesForGuiSelection(); var newItem = new ToolStripMenuItem(Resources.Properties) { ToolTipText = Resources.Properties_ToolTip, Image = Resources.PropertiesIcon, - Enabled = propertyInfos.Any() + Enabled = canShowProperties }; - - var guiCommandHandler = gui.CommandHandler; - if (guiCommandHandler != null) - { - newItem.Click += (s, e) => guiCommandHandler.ShowProperties(); - } - + newItem.Click += (s, e) => commandHandler.ShowProperties(); + return newItem; } } Index: Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs =================================================================== diff -u -rbc238ea43fae81b8a49aa2bdb2c8349815c46039 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision bc238ea43fae81b8a49aa2bdb2c8349815c46039) +++ Core/Common/src/Core.Common.Gui/GuiCommandHandler.cs (.../GuiCommandHandler.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -133,6 +133,16 @@ return gui.ApplicationCore.GetSupportedFileImporters(gui.Selection).Any(); } + public bool CanExportFromGuiSelection() + { + return gui.ApplicationCore.GetSupportedFileExporters(gui.Selection).Any(); + } + + public bool CanShowPropertiesForGuiSelection() + { + return gui.Plugins.SelectMany(p => p.GetPropertyInfos()).Any(pi => pi.ObjectType == gui.Selection.GetType()); + } + public void ImportOn(object target, IFileImporter importer = null) { try Index: Core/Common/src/Core.Common.Gui/GuiExportHandler.cs =================================================================== diff -u -rf8109189a1cf9b9905556f12faf82c1035c283a4 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision f8109189a1cf9b9905556f12faf82c1035c283a4) +++ Core/Common/src/Core.Common.Gui/GuiExportHandler.cs (.../GuiExportHandler.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -98,10 +98,11 @@ { log.Info(Resources.GuiExportHandler_ExporterItemUsingFileOpenDialog_Start_exporting); + var windowTitle = string.Format(Resources.GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_DataType_0_file_to_export_to, exporter.Name); var dlg = new SaveFileDialog { Filter = exporter.FileFilter, - Title = Resources.GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_file_to_export_to, + Title = windowTitle, FilterIndex = 2 }; if (dlg.ShowDialog() == DialogResult.OK) Index: Core/Common/src/Core.Common.Gui/GuiImportHandler.cs =================================================================== diff -u -rbc238ea43fae81b8a49aa2bdb2c8349815c46039 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision bc238ea43fae81b8a49aa2bdb2c8349815c46039) +++ Core/Common/src/Core.Common.Gui/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -198,11 +198,12 @@ /// private void GetImportedItemsUsingFileOpenDialog(IFileImporter importer, object target) { + var windowTitle = string.Format(Resources.GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_DataType_0_file_to_import_from, importer.Name); var dialog = new OpenFileDialog { Filter = importer.FileFilter, Multiselect = true, - Title = Resources.GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_file_to_import_from, + Title = windowTitle, RestoreDirectory = true }; Index: Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs =================================================================== diff -u -r8a9a2efad299327b082088189b9a37c32c55a890 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision 8a9a2efad299327b082088189b9a37c32c55a890) +++ Core/Common/src/Core.Common.Gui/IGuiCommandHandler.cs (.../IGuiCommandHandler.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -98,6 +98,17 @@ /// bool CanImportToGuiSelection(); + /// + /// Indicates if there are exporters for the current Gui.Selection + /// + bool CanExportFromGuiSelection(); + + /// + /// Indicates if there is a property view object for the current . + /// + /// true if a property view is defined, false otherwise. + bool CanShowPropertiesForGuiSelection(); + object GetDataOfActiveView(); void OpenLogFileExternal(); Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -r231804c353b32db8e1421cfb776801a9b0677541 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 231804c353b32db8e1421cfb776801a9b0677541) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -1196,11 +1196,12 @@ } /// - /// Looks up a localized string similar to Selecteer een bestand om naartoe te exporteren.. + /// Looks up a localized string similar to Selecteer een bestand met {0} om naartoe te exporteren.. /// - public static string GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_file_to_export_to { + public static string GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_DataType_0_file_to_export_to { get { - return ResourceManager.GetString("GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_file_to_export_to", resourceCulture); + return ResourceManager.GetString("GuiExportHandler_ExporterItemUsingFileOpenDialog_Select_a_DataType_0_file_to_expo" + + "rt_to", resourceCulture); } } @@ -1234,12 +1235,12 @@ } /// - /// Looks up a localized string similar to Selecteer een bestand om eruit te importeren.... + /// Looks up a localized string similar to Selecteer een bestand met {0} om eruit te importeren.... /// - public static string GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_file_to_import_from { + public static string GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_DataType_0_file_to_import_from { get { - return ResourceManager.GetString("GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_file_to_import_from" + - "", resourceCulture); + return ResourceManager.GetString("GuiImportHandler_GetImportedItemsUsingFileOpenDialog_Select_a_DataType_0_file_to_" + + "import_from", resourceCulture); } } Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -r231804c353b32db8e1421cfb776801a9b0677541 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 231804c353b32db8e1421cfb776801a9b0677541) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -578,8 +578,8 @@ Alle vensters zijn gemaakt. - - Selecteer een bestand om eruit te importeren... + + Selecteer een bestand met {0} om eruit te importeren... Menu's en werkbalken instellen... @@ -776,8 +776,8 @@ Exporteren afgerond. - - Selecteer een bestand om naartoe te exporteren. + + Selecteer een bestand met {0} om naartoe te exporteren. Exporteren gestart. Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs =================================================================== diff -u -reb7f8fe1e85f00faf16a1cddef014728d60a2b19 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision eb7f8fe1e85f00faf16a1cddef014728d60a2b19) +++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -289,7 +289,7 @@ public ContextMenuBuilder Get(ITreeNode treeNode) { - return new ContextMenuBuilder(this, treeNode); + return new ContextMenuBuilder(CommandHandler, treeNode); } public void Dispose() Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs =================================================================== diff -u -reb7f8fe1e85f00faf16a1cddef014728d60a2b19 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision eb7f8fe1e85f00faf16a1cddef014728d60a2b19) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -46,7 +46,7 @@ public void Constructor_Gui_NewInstance() { // Call - var builder = new ContextMenuBuilder(MockRepository.GenerateMock(), MockRepository.GenerateMock()); + var builder = new ContextMenuBuilder(MockRepository.GenerateMock(), MockRepository.GenerateMock()); // Assert Assert.IsInstanceOf(builder); @@ -122,9 +122,9 @@ public void AddOpenItem_WithGuiWhenBuild_ItemAddedToContextMenu() { // Setup - var guiStub = mocks.StrictMock(); - guiStub.Expect(g => g.Plugins).Return(new GuiPlugin[0]); - var builder = new ContextMenuBuilder(guiStub, MockRepository.GenerateMock()); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanOpenDefaultViewForSelection()).Return(true); + var builder = new ContextMenuBuilder(commandHandlerMock, MockRepository.GenerateMock()); mocks.ReplayAll(); @@ -161,9 +161,9 @@ public void AddExportItem_WithGuiWhenBuild_ItemAddedToContextMenu() { // Setup - var guiStub = mocks.StrictMock(); - guiStub.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - var builder = new ContextMenuBuilder(guiStub, MockRepository.GenerateMock()); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanExportFromGuiSelection()).Return(true); + var builder = new ContextMenuBuilder(commandHandlerMock, MockRepository.GenerateMock()); mocks.ReplayAll(); @@ -200,9 +200,9 @@ public void AddImportItem_WithGuiWhenBuild_ItemAddedToContextMenu() { // Setup - var guiStub = mocks.StrictMock(); - guiStub.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - var builder = new ContextMenuBuilder(guiStub, MockRepository.GenerateMock()); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanImportToGuiSelection()).Return(true); + var builder = new ContextMenuBuilder(commandHandlerMock, MockRepository.GenerateMock()); mocks.ReplayAll(); @@ -239,10 +239,9 @@ public void AddPropertiesItem_WithGuiWhenBuild_ItemAddedToContextMenu() { // Setup - var guiStub = mocks.StrictMock(); - guiStub.Expect(g => g.Plugins).Return(new GuiPlugin[0]); - guiStub.Expect(g => g.CommandHandler).Return(null); - var builder = new ContextMenuBuilder(guiStub, MockRepository.GenerateMock()); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanShowPropertiesForGuiSelection()).Return(true); + var builder = new ContextMenuBuilder(commandHandlerMock, MockRepository.GenerateMock()); mocks.ReplayAll(); Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs =================================================================== diff -u -r41c77f9f36ae74a406fd382187426cc06d2b0200 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 41c77f9f36ae74a406fd382187426cc06d2b0200) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using Core.Common.Base; using Core.Common.Controls; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Properties; @@ -14,10 +12,6 @@ public class ContextMenuItemFactoryTest { private MockRepository mocks; - private readonly IList pluginList = new GuiPlugin[] - { - new TestGuiPlugin() - }; [SetUp] public void SetUp() @@ -26,35 +20,23 @@ } [Test] - public void Constructor_WithoutGui_ThrowsArgumentNullException() + public void Constructor_WithoutCommandHandler_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new GuiContextMenuItemFactory(null, null); + TestDelegate test = () => new GuiContextMenuItemFactory(null); // Assert var message = Assert.Throws(test).Message; StringAssert.StartsWith(Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui, message); - StringAssert.EndsWith("gui", message); + StringAssert.EndsWith("commandHandler", message); } [Test] - public void Constructor_WithoutTreeNode_ThrowsArgumentNullException() - { - // Call - TestDelegate test = () => new GuiContextMenuItemFactory(mocks.StrictMock(), null); - - // Assert - var message = Assert.Throws(test).Message; - StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node, message); - StringAssert.EndsWith("treeNode", message); - } - - [Test] public void Constructor_WithGuiAndTreeNode_NewInstance() { // Call - var result = new GuiContextMenuItemFactory(mocks.StrictMock(), mocks.StrictMock()); + var result = new GuiContextMenuItemFactory(mocks.StrictMock()); // Assert Assert.IsInstanceOf(result); @@ -64,12 +46,10 @@ public void CreateOpenItem_NoViewersForType_Disabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = ""; - guiMock.Expect(g => g.Plugins).Return(pluginList); + var guiMock = mocks.StrictMock(); + guiMock.Expect(ch => ch.CanOpenDefaultViewForSelection()).Return(false); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); + var contextMenuFactory = new GuiContextMenuItemFactory(guiMock); mocks.ReplayAll(); @@ -84,15 +64,13 @@ } [Test] - public void CreateOpentem_ImportersForType_Enabled() + public void CreateOpenItem_ViewersForType_Enabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = 0; - guiMock.Expect(g => g.Plugins).Return(pluginList); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanOpenDefaultViewForSelection()).Return(true); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); mocks.ReplayAll(); @@ -110,21 +88,11 @@ public void CreateExportItem_NoImporterExportersForType_Disabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - var applicationCore = new ApplicationCore(); - var data = 0; - treeNodeMock.Tag = data; + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanExportFromGuiSelection()).Return(false); - var testApplicationPlugin = new TestApplicationPlugin(); - testApplicationPlugin.ExporterMock = mocks.StrictMock(); - testApplicationPlugin.ExporterMock.Expect(e => e.SourceTypes()).Return(new Type[0]); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); - applicationCore.AddPlugin(testApplicationPlugin); - guiMock.Expect(g => g.ApplicationCore).Return(applicationCore); - - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); - mocks.ReplayAll(); // Call @@ -143,22 +111,11 @@ public void CreateExportItem_ExportersForType_Enabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - var applicationCore = new ApplicationCore(); - var data = 0; - treeNodeMock.Tag = data; + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanExportFromGuiSelection()).Return(true); - var testApplicationPlugin = new TestApplicationPlugin(); - testApplicationPlugin.ExporterMock = mocks.StrictMock(); - testApplicationPlugin.ExporterMock.Expect(e => e.SourceTypes()).Return(new[] { data.GetType() }); - testApplicationPlugin.ExporterMock.Expect(e => e.CanExportFor(data)).Return(true); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); - applicationCore.AddPlugin(testApplicationPlugin); - guiMock.Expect(g => g.ApplicationCore).Return(applicationCore); - - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); - mocks.ReplayAll(); // Call @@ -177,20 +134,11 @@ public void CreateImportItem_NoImportersForType_Disabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - var applicationCore = new ApplicationCore(); - var data = 0; - treeNodeMock.Tag = data; + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanImportToGuiSelection()).Return(false); - var testApplicationPlugin = new TestApplicationPlugin(); - testApplicationPlugin.ImporterMock = mocks.StrictMock(); - testApplicationPlugin.ImporterMock.Expect(e => e.SupportedItemTypes).Return(new Type[0]) ; + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); - applicationCore.AddPlugin(testApplicationPlugin); - guiMock.Expect(g => g.ApplicationCore).Return(applicationCore); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); - mocks.ReplayAll(); // Call @@ -209,21 +157,11 @@ public void CreateImportItem_ImportersForType_Enabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - var applicationCore = new ApplicationCore(); - var data = 0; - treeNodeMock.Tag = data; + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanImportToGuiSelection()).Return(true); - var testApplicationPlugin = new TestApplicationPlugin(); - testApplicationPlugin.ImporterMock = mocks.StrictMock(); - testApplicationPlugin.ImporterMock.Expect(e => e.SupportedItemTypes).Return(new[] { data.GetType() }); - testApplicationPlugin.ImporterMock.Expect(e => e.CanImportOn(data)).Return(true); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); - applicationCore.AddPlugin(testApplicationPlugin); - guiMock.Expect(g => g.ApplicationCore).Return(applicationCore); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); - mocks.ReplayAll(); // Call @@ -242,13 +180,11 @@ public void CreatePropertiesItem_PropertieInfoForType_Enabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = 0; - guiMock.Expect(g => g.Plugins).Return(pluginList); - guiMock.Expect(g => g.CommandHandler).Return(null); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanShowPropertiesForGuiSelection()).Return(true); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); + mocks.ReplayAll(); // Call @@ -267,13 +203,11 @@ public void CreatePropertiesItem_NoPropertieInfoForType_Disabled() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = ""; - guiMock.Expect(g => g.Plugins).Return(pluginList); - guiMock.Expect(g => g.CommandHandler).Return(null); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); + var commandHandlerMock = mocks.StrictMock(); + commandHandlerMock.Expect(ch => ch.CanShowPropertiesForGuiSelection()).Return(false); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); + mocks.ReplayAll(); // Call @@ -289,39 +223,15 @@ } [Test] - public void CreatePropertiesItem_ClickWithoutHandler_NoExceptions() - { - // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = 0; - guiMock.Expect(g => g.Plugins).Return(pluginList); - guiMock.Expect(g => g.CommandHandler).Return(null); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); - - mocks.ReplayAll(); - - var item = contextMenuFactory.CreatePropertiesItem(); - - // Call & Assert - item.PerformClick(); - - mocks.VerifyAll(); - } - - [Test] public void CreatePropertiesItem_ClickWithHandler_NoExceptions() { // Setup - var guiMock = mocks.StrictMock(); - var treeNodeMock = mocks.Stub(); - treeNodeMock.Tag = 0; var commandHandlerMock = mocks.StrictMock(); - guiMock.Expect(g => g.Plugins).Return(pluginList); - guiMock.Expect(g => g.CommandHandler).Return(commandHandlerMock); + commandHandlerMock.Expect(ch => ch.CanShowPropertiesForGuiSelection()).Return(true); commandHandlerMock.Expect(ch => ch.ShowProperties()); - var contextMenuFactory = new GuiContextMenuItemFactory(guiMock, treeNodeMock); + var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock); + mocks.ReplayAll(); var item = contextMenuFactory.CreatePropertiesItem(); @@ -332,39 +242,4 @@ mocks.VerifyAll(); } } - - public class TestApplicationPlugin : ApplicationPlugin - { - public IFileExporter ExporterMock { get; set; } - public IFileImporter ImporterMock { get; set; } - - public override IEnumerable GetFileExporters() - { - yield return ExporterMock; - } - - public override IEnumerable GetFileImporters() - { - yield return ImporterMock; - } - } - - public class TestGuiPlugin : GuiPlugin - { - public override IEnumerable GetPropertyInfos() - { - yield return new PropertyInfo - { - ObjectType = typeof(int) - }; - } - - public override IEnumerable GetViewInfoObjects() - { - yield return new ViewInfo - { - DataType = typeof(int) - }; - } - } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismNodePresenterTest.cs =================================================================== diff -u -ra80efa8773c3efec54ba44940945b03bc3f3ff7e -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismNodePresenterTest.cs (.../FailureMechanismNodePresenterTest.cs) (revision a80efa8773c3efec54ba44940945b03bc3f3ff7e) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/FailureMechanismNodePresenterTest.cs (.../FailureMechanismNodePresenterTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -139,7 +139,7 @@ } [Test] - public void GetContextMenu_NoGui_ReturnsContextMenuWithItems() + public void GetContextMenu_NoGuiCommandHandler_ReturnsContextMenuWithItems() { // Setup var nodeMock = mocks.StrictMock(); @@ -168,18 +168,14 @@ } [Test] - public void GetContextMenu_WithGui_ReturnsContextMenuWithCommonItems() + public void GetContextMenu_WithGuiCommandHandler_ReturnsContextMenuWithCommonItems() { // Setup var nodeMock = mocks.Stub(); - var guiMock = mocks.DynamicMock(); var guiHandlerMock = mocks.DynamicMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - guiMock.Expect(g => g.CommandHandler).Return(guiHandlerMock); - guiMock.Expect(g => g.Plugins).Return(new GuiPlugin[0]); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiHandlerMock, nodeMock)); var nodePresenter = new FailureMechanismNodePresenter(contextMenuProvider); var failureMechanism = new FailureMechanismPlaceholder("test"); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/PlaceholderWithReadonlyNameNodePresenterTest.cs =================================================================== diff -u -re6e92cb42b1e4983add2406300958b6b116ba781 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/PlaceholderWithReadonlyNameNodePresenterTest.cs (.../PlaceholderWithReadonlyNameNodePresenterTest.cs) (revision e6e92cb42b1e4983add2406300958b6b116ba781) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/NodePresenters/PlaceholderWithReadonlyNameNodePresenterTest.cs (.../PlaceholderWithReadonlyNameNodePresenterTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -251,14 +251,10 @@ { // Setup var nodeMock = mocks.Stub(); - var guiMock = mocks.DynamicMock(); var guiHandlerMock = mocks.DynamicMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - guiMock.Expect(g => g.CommandHandler).Return(guiHandlerMock); - guiMock.Expect(g => g.Plugins).Return(new GuiPlugin[0]); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiHandlerMock, nodeMock)); var nodePresenter = new PlaceholderWithReadonlyNameNodePresenter(contextMenuProvider); var placeholderData = new InputPlaceholder("test"); @@ -287,14 +283,10 @@ { // Setup var nodeMock = mocks.Stub(); - var guiMock = mocks.DynamicMock(); var guiHandlerMock = mocks.DynamicMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - guiMock.Expect(g => g.CommandHandler).Return(guiHandlerMock); - guiMock.Expect(g => g.Plugins).Return(new GuiPlugin[0]); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiHandlerMock, nodeMock)); var nodePresenter = new PlaceholderWithReadonlyNameNodePresenter(contextMenuProvider); var placeholderData = new OutputPlaceholder("test"); @@ -323,14 +315,10 @@ { // Setup var nodeMock = mocks.Stub(); - var guiMock = mocks.DynamicMock(); var guiHandlerMock = mocks.DynamicMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()); - guiMock.Expect(g => g.CommandHandler).Return(guiHandlerMock); - guiMock.Expect(g => g.Plugins).Return(new GuiPlugin[0]); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiHandlerMock, nodeMock)); var nodePresenter = new PlaceholderWithReadonlyNameNodePresenter(contextMenuProvider); var placeholderData = new PlaceholderWithReadonlyName("test"); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingFailureMechanismNodePresenter.cs =================================================================== diff -u -ra670d0895ffaba9ace8c0c6e5f9a10103e61a205 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingFailureMechanismNodePresenter.cs (.../PipingFailureMechanismNodePresenter.cs) (revision a670d0895ffaba9ace8c0c6e5f9a10103e61a205) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingFailureMechanismNodePresenter.cs (.../PipingFailureMechanismNodePresenter.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -28,7 +28,7 @@ /// public class PipingFailureMechanismNodePresenter : RingtoetsNodePresenterBase { - public IContextMenuBuilderProvider ContextMenuBuilderProvider { get; set; } + public IContextMenuBuilderProvider ContextMenuBuilderProvider { private get; set; } /// /// Injection points for a method to cause a collection of to be scheduled for execution. Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingSurfaceLineCollectionNodePresenter.cs =================================================================== diff -u -re388ea76d1d044298cc89156c8744fbea1bcb736 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingSurfaceLineCollectionNodePresenter.cs (.../PipingSurfaceLineCollectionNodePresenter.cs) (revision e388ea76d1d044298cc89156c8744fbea1bcb736) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/NodePresenters/PipingSurfaceLineCollectionNodePresenter.cs (.../PipingSurfaceLineCollectionNodePresenter.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -1,12 +1,10 @@ -using System; -using System.Collections; +using System.Collections; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Common.Controls; - -using Ringtoets.Common.Forms.Extensions; +using Core.Common.Gui; using Ringtoets.Common.Forms.NodePresenters; using Ringtoets.Piping.Data; @@ -20,11 +18,7 @@ /// public class PipingSurfaceLineCollectionNodePresenter : RingtoetsNodePresenterBase> { - /// - /// Injects the action to be performed when importing - /// instances to . - /// - public Action ImportSurfaceLinesAction { private get; set; } + public IContextMenuBuilderProvider ContextMenuBuilderProvider { private get; set; } protected override void UpdateNode(ITreeNode parentNode, ITreeNode node, IEnumerable nodeData) { @@ -35,37 +29,23 @@ protected override IEnumerable GetChildNodeObjects(IEnumerable nodeData) { - foreach (var pipingSurfaceLine in nodeData) - { - yield return pipingSurfaceLine; - } + return nodeData; } protected override ContextMenuStrip GetContextMenu(ITreeNode sender, IEnumerable nodeData) { - if (ImportSurfaceLinesAction != null) + if (ContextMenuBuilderProvider == null) { - return CreateContextMenu(); + return null; } - return null; + return ContextMenuBuilderProvider + .Get(sender) + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddImportItem() + .AddExportItem() + .Build(); } - - private ContextMenuStrip CreateContextMenu() - { - var rootMenu = new ContextMenuStrip(); - - if (ImportSurfaceLinesAction != null) - { - rootMenu.AddMenuItem(Resources.Import_SurfaceLines, Resources.Import_SurfaceLines_Tooltip, - Resources.ImportIcon, ImportItemOnClick); - } - - return rootMenu; - } - - private void ImportItemOnClick(object sender, EventArgs eventArgs) - { - ImportSurfaceLinesAction(); - } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -ra670d0895ffaba9ace8c0c6e5f9a10103e61a205 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision a670d0895ffaba9ace8c0c6e5f9a10103e61a205) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -46,7 +46,7 @@ }; yield return new PipingSurfaceLineCollectionNodePresenter { - ImportSurfaceLinesAction = Gui.CommandHandler.ImportToGuiSelection + ContextMenuBuilderProvider = Gui.ContextMenuProvider }; yield return new PipingSurfaceLineNodePresenter(); yield return new PipingSoilProfileCollectionNodePresenter Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs =================================================================== diff -u -reb7f8fe1e85f00faf16a1cddef014728d60a2b19 -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs (.../PipingFailureMechanismNodePresenterTest.cs) (revision eb7f8fe1e85f00faf16a1cddef014728d60a2b19) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingFailureMechanismNodePresenterTest.cs (.../PipingFailureMechanismNodePresenterTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -362,13 +362,10 @@ var mocks = new MockRepository(); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()).Repeat.Twice(); - var nodeMock = mocks.Stub(); - var guiMock = mocks.StrictMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()).Repeat.Twice(); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(null, nodeMock)); var dataMock = mocks.StrictMock(); dataMock.Calculations.Add(new PipingCalculation @@ -420,7 +417,7 @@ } [Test] - public void GetContextMenu_NoGui_ReturnsEmptyContextMenu() + public void GetContextMenu_NoGuiCommandHandler_ReturnsEmptyContextMenu() { // Setup var mocks = new MockRepository(); @@ -458,11 +455,10 @@ // Setup var mocks = new MockRepository(); var nodeMock = mocks.Stub(); - var guiMock = mocks.StrictMock(); - guiMock.Expect(g => g.ApplicationCore).Return(new ApplicationCore()).Repeat.Twice(); + var commandHandlerMock = mocks.DynamicMock(); var contextMenuProvider = mocks.StrictMock(); - contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(guiMock, nodeMock)); + contextMenuProvider.Expect(cmp => cmp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(commandHandlerMock, nodeMock)); var nodePresenter = new PipingFailureMechanismNodePresenter { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingSurfaceLineCollectionNodePresenterTest.cs =================================================================== diff -u -r61161720b379645f400606e868e2a1286c17348d -r5bdfe106fefb36f7e677da7e75afec1eba7eedd3 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingSurfaceLineCollectionNodePresenterTest.cs (.../PipingSurfaceLineCollectionNodePresenterTest.cs) (revision 61161720b379645f400606e868e2a1286c17348d) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingSurfaceLineCollectionNodePresenterTest.cs (.../PipingSurfaceLineCollectionNodePresenterTest.cs) (revision 5bdfe106fefb36f7e677da7e75afec1eba7eedd3) @@ -3,7 +3,10 @@ using System.ComponentModel; using System.Drawing; using System.Linq; +using System.Windows.Forms; using Core.Common.Controls; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; using Core.Common.TestUtils; using Core.Common.Utils.Collections; using NUnit.Framework; @@ -273,10 +276,7 @@ var dataMock = mocks.StrictMock>(); mocks.ReplayAll(); - var nodePresenter = new PipingSurfaceLineCollectionNodePresenter - { - ImportSurfaceLinesAction = null - }; + var nodePresenter = new PipingSurfaceLineCollectionNodePresenter(); // Call var contextMenu = nodePresenter.GetContextMenu(nodeMock, dataMock); @@ -287,31 +287,80 @@ } [Test] - public void GetContextMenu_SurfaceLinesImportActionSet_HaveImportSurfaceLinesItemInContextMenu() + public void GetContextMenu_NoContextMenuBuilderProviderSet_ReturnsNull() { // Setup var mocks = new MockRepository(); var nodeMock = mocks.StrictMock(); var dataMock = mocks.StrictMock>(); - var actionStub = mocks.Stub(); mocks.ReplayAll(); + var nodePresenter = new PipingSurfaceLineCollectionNodePresenter(); + + // Call + var returnedContextMenu = nodePresenter.GetContextMenu(nodeMock, dataMock); + + // Assert + Assert.IsNull(returnedContextMenu); + + mocks.VerifyAll(); // Expect no calls on arguments + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void GetContextMenu_ContextMenuBuilderProviderSet_HaveImportSurfaceLinesItemInContextMenu(bool importExportEnabled) + { + // Setup + var mocks = new MockRepository(); + var nodeMock = mocks.StrictMock(); + var dataMock = mocks.StrictMock>(); + var menuBuilderProviderMock = mocks.StrictMock(); + var commandHandlerMock = mocks.StrictMock(); + menuBuilderProviderMock.Expect(mbp => mbp.Get(null)).IgnoreArguments().Return(new ContextMenuBuilder(commandHandlerMock, nodeMock)); + + commandHandlerMock.Expect(ch => ch.CanExportFromGuiSelection()).Return(importExportEnabled); + commandHandlerMock.Expect(ch => ch.CanImportToGuiSelection()).Return(importExportEnabled); + + mocks.ReplayAll(); + var nodePresenter = new PipingSurfaceLineCollectionNodePresenter { - ImportSurfaceLinesAction = actionStub + ContextMenuBuilderProvider = menuBuilderProviderMock }; // Call var returnedContextMenu = nodePresenter.GetContextMenu(nodeMock, dataMock); // Assert - Assert.AreEqual(1, returnedContextMenu.Items.Count); - var importItem = returnedContextMenu.Items[0]; - Assert.AreEqual("Importeer profielmetingen", importItem.Text); - Assert.AreEqual("Importeer nieuwe profielmetingen van een *.csv bestand.", importItem.ToolTipText); - Assert.AreEqual(16, importItem.Image.Width); - Assert.AreEqual(16, importItem.Image.Height); - mocks.VerifyAll(); // Expect no calls on arguments + Assert.AreEqual(5, returnedContextMenu.Items.Count); + var expandAllItem = returnedContextMenu.Items[0]; + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Expand_all, expandAllItem.Text); + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Expand_all_ToolTip, expandAllItem.ToolTipText); + TestHelper.AssertImagesAreEqual(Core.Common.Gui.Properties.Resources.ExpandAllIcon, expandAllItem.Image); + Assert.IsTrue(expandAllItem.Enabled); + + var collapseAllItem = returnedContextMenu.Items[1]; + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Collapse_all, collapseAllItem.Text); + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Collapse_all_ToolTip, collapseAllItem.ToolTipText); + TestHelper.AssertImagesAreEqual(Core.Common.Gui.Properties.Resources.CollapseAllIcon, collapseAllItem.Image); + Assert.IsTrue(collapseAllItem.Enabled); + + var importItem = returnedContextMenu.Items[3]; + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Import, importItem.Text); + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Import_ToolTip, importItem.ToolTipText); + TestHelper.AssertImagesAreEqual(Core.Common.Gui.Properties.Resources.ImportIcon, importItem.Image); + Assert.AreEqual(importExportEnabled, importItem.Enabled); + + var exportItem = returnedContextMenu.Items[4]; + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Export, exportItem.Text); + Assert.AreEqual(Core.Common.Gui.Properties.Resources.Export_ToolTip, exportItem.ToolTipText); + TestHelper.AssertImagesAreEqual(Core.Common.Gui.Properties.Resources.ExportIcon, exportItem.Image); + Assert.AreEqual(importExportEnabled, exportItem.Enabled); + + Assert.IsInstanceOf(returnedContextMenu.Items[2]); + + mocks.VerifyAll(); } [Test]