public void EditValue_Always_OpenViewForData() { // Setup var editor = new ViewPropertyEditor(); var data = new object(); var mocks = new MockRepository(); var commands = mocks.StrictMock <IViewCommands>(); commands.Expect(c => c.OpenView(data)); mocks.ReplayAll(); IViewCommands originalValue = ViewPropertyEditor.ViewCommands; try { ViewPropertyEditor.ViewCommands = commands; // Call editor.EditValue(null, null, data); // Assert mocks.VerifyAll(); // Expect 'OpenView' to be called. } finally { ViewPropertyEditor.ViewCommands = originalValue; } }
/// <summary> /// Creates a new instance of <see cref="ContextMenuBuilder"/>. /// </summary> /// <param name="featureCommandHandler">The <see cref="IApplicationFeatureCommands"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="importCommandHandler">The <see cref="IImportCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="exportCommandHandler">The <see cref="IExportCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="updateCommandHandler">The <see cref="IUpdateCommandHandler"/> from which to obtain /// information to render and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="viewCommands">The <see cref="IViewCommands"/> from which to obtain information to render /// and bind actions to the items of the <see cref="ContextMenu"/>.</param> /// <param name="dataValue">The data object for which to create a <see cref="ContextMenuStrip"/>.</param> /// <param name="treeViewControl">The <see cref="TreeViewControl"/> to use while executing the <see cref="ContextMenuStrip"/> actions.</param> /// <exception cref="ContextMenuBuilderException">Thrown when any input argument is <c>null</c>.</exception> public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, IUpdateCommandHandler updateCommandHandler, IViewCommands viewCommands, object dataValue, TreeViewControl treeViewControl) { try { guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler, importCommandHandler, exportCommandHandler, updateCommandHandler, viewCommands, dataValue); treeViewItemsFactory = new TreeViewContextMenuItemFactory(dataValue, treeViewControl); } catch (ArgumentNullException e) { throw new ContextMenuBuilderException(Resources.ContextMenuBuilder_ContextMenuBuilder_Cannot_create_instances_of_factories, e); } contextMenu = new ContextMenuStrip(); }
/// <summary> /// Creates a new instance of <see cref="AssessmentSectionCompositionChangeHandler"/>. /// </summary> /// <param name="viewCommands">The view commands used to close views for failure mechanisms /// that are not part of the assembly.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="viewCommands"/> /// is <c>null</c>.</exception> public AssessmentSectionCompositionChangeHandler(IViewCommands viewCommands) { if (viewCommands == null) { throw new ArgumentNullException(nameof(viewCommands)); } this.viewCommands = viewCommands; }
public ParameterMgmtViewModel(IRegionManager regionManager, IViewCommands viewCommands) { _regionManager = regionManager; _viewCommands = viewCommands; OverviewCommand = new DelegateCommand(OverviewExecuted); MonitoringCommand = new DelegateCommand(MonitoringExecuted); ConfigurationCommand = new DelegateCommand(ConfigurationExecuted); AlarmCommand = new DelegateCommand(AlarmExecuted); _viewCommands.OverviewCommand.RegisterCommand(OverviewCommand); _viewCommands.MonitoringCommand.RegisterCommand(MonitoringCommand); _viewCommands.ConfigurationCommand.RegisterCommand(ConfigurationCommand); _viewCommands.AlarmCommand.RegisterCommand(AlarmCommand); }
/// <summary> /// Creates a new instance of <see cref="GuiContextMenuItemFactory"/>. /// </summary> /// <param name="applicationFeatureCommandHandler">The <see cref="IApplicationFeatureCommands"/> /// which contains information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="importCommandHandler">The <see cref="IImportCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="exportCommandHandler">The <see cref="IExportCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="updateCommandHandler">The <see cref="IUpdateCommandHandler"/> which contains /// information for creating the <see cref="ToolStripItem"/>.</param> /// <param name="viewCommandsHandler">The <see cref="IViewCommands"/> which contains information for /// creating the <see cref="ToolStripItem"/>.</param> /// <param name="dataObject">The data object for which to create <see cref="ToolStripItem"/>.</param> /// <exception cref="ArgumentNullException">Thrown when any input argument is <c>null</c>.</exception> public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler, IImportCommandHandler importCommandHandler, IExportCommandHandler exportCommandHandler, IUpdateCommandHandler updateCommandHandler, IViewCommands viewCommandsHandler, object dataObject) { if (applicationFeatureCommandHandler == null) { throw new ArgumentNullException(nameof(applicationFeatureCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_gui); } if (importCommandHandler == null) { throw new ArgumentNullException(nameof(importCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_import_handler); } if (exportCommandHandler == null) { throw new ArgumentNullException(nameof(exportCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_export_handler); } if (updateCommandHandler == null) { throw new ArgumentNullException(nameof(updateCommandHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_update_handler); } if (viewCommandsHandler == null) { throw new ArgumentNullException(nameof(viewCommandsHandler), Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_view_commands); } if (dataObject == null) { throw new ArgumentNullException(nameof(dataObject), Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data); } this.applicationFeatureCommandHandler = applicationFeatureCommandHandler; this.importCommandHandler = importCommandHandler; this.exportCommandHandler = exportCommandHandler; this.updateCommandHandler = updateCommandHandler; viewCommands = viewCommandsHandler; this.dataObject = dataObject; }
/// <summary> /// Creates a new instance of <see cref="ReferenceLineUpdateHandler"/>. /// </summary> /// <param name="assessmentSection">The assessment section to remove data for.</param> /// <param name="viewCommands">The view commands used to close views for removed data.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public ReferenceLineUpdateHandler(IAssessmentSection assessmentSection, IViewCommands viewCommands) { if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } if (viewCommands == null) { throw new ArgumentNullException(nameof(viewCommands)); } this.assessmentSection = assessmentSection; this.viewCommands = viewCommands; }
/// <summary> /// Creates a new instance of <see cref="DuneLocationsReplacementHandler"/>. /// </summary> /// <param name="viewCommands">The view commands used to close views for removed data.</param> /// <param name="failureMechanism">The failure mechanism to update.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public DuneLocationsReplacementHandler(IViewCommands viewCommands, DuneErosionFailureMechanism failureMechanism) { if (viewCommands == null) { throw new ArgumentNullException(nameof(viewCommands)); } if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } this.viewCommands = viewCommands; this.failureMechanism = failureMechanism; duneLocationsReader = new DuneLocationsReader(); }
/// <summary> /// Creates a new instance of <see cref="ProjectExplorer"/>. /// </summary> /// <param name="viewCommands">The provider of view related commands.</param> /// <param name="treeNodeInfos">The <see cref="IEnumerable{T}"/> of <see cref="TreeNodeInfo"/> which /// are used to draw nodes.</param> /// <exception cref="ArgumentNullException">Thrown when either: /// <list type="bullet"> /// <item><paramref name="viewCommands"/> is <c>null</c>,</item> /// <item><paramref name="treeNodeInfos"/> is <c>null</c></item> /// </list> /// </exception> public ProjectExplorer(IViewCommands viewCommands, IEnumerable <TreeNodeInfo> treeNodeInfos) { if (viewCommands == null) { throw new ArgumentNullException(nameof(viewCommands)); } if (treeNodeInfos == null) { throw new ArgumentNullException(nameof(treeNodeInfos)); } InitializeComponent(); this.viewCommands = viewCommands; RegisterTreeNodeInfos(treeNodeInfos); BindTreeInteractionEvents(); }
public ViewBarCommandViewModel(IViewCommands viewCommands) { _viewCommands = viewCommands; }