Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/RibbonTest.cs =================================================================== diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -r75c007324755a9f899f7fc5639ff873311343bdc --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/RibbonTest.cs (.../RibbonTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/RibbonTest.cs (.../RibbonTest.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -93,6 +93,7 @@ // Assert CollectionAssert.AreEqual(new[] { command }, result); + mocks.VerifyAll(); } [Test] @@ -122,6 +123,7 @@ // Assert Assert.AreEqual(isChecked, toggleProjectExplorerButton.IsChecked); + mocks.VerifyAll(); } [Test] Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AddAssessmentSectionCommand.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AddAssessmentSectionCommand.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AddAssessmentSectionCommand.cs (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Controls.Commands; + +namespace Ringtoets.Integration.Forms.Commands +{ + /// + /// This class describes commands which are used to execute in the GUI. + /// + public class AddAssessmentSectionCommand : ICommand + { + private readonly IAssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler; + + /// + /// Creates a new instance of . + /// + /// The to execute. + /// Throw when is null. + public AddAssessmentSectionCommand(IAssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler) + { + if (assessmentSectionFromFileCommandHandler == null) + { + throw new ArgumentNullException("assessmentSectionFromFileCommandHandler"); + } + this.assessmentSectionFromFileCommandHandler = assessmentSectionFromFileCommandHandler; + } + + public bool Enabled + { + get + { + return true; + } + } + + public bool Checked + { + get + { + return true; + } + } + + public void Execute(params object[] arguments) + { + assessmentSectionFromFileCommandHandler.CreateAssessmentSectionFromFile(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs =================================================================== diff -u -r50b203a8d5c805fc548fb6b92c70a847190da6a5 -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 50b203a8d5c805fc548fb6b92c70a847190da6a5) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -23,12 +23,12 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using Core.Common.Base.Data; using Core.Common.Gui; using Core.Common.Gui.Forms.ViewHost; using Core.Common.IO.Exceptions; using log4net; using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.IO; using Ringtoets.Common.IO.Exceptions; @@ -39,9 +39,9 @@ namespace Ringtoets.Integration.Forms.Commands { /// - /// This class provides concrete implementation for . + /// This class is responsible for adding an from a predefined location. /// - public class AssessmentSectionFromFileCommandHandler + public class AssessmentSectionFromFileCommandHandler : IAssessmentSectionFromFileCommandHandler { private static readonly ILog log = LogManager.GetLogger(typeof(AssessmentSectionFromFileCommandHandler)); private readonly string shapeFileDirectory = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory(); @@ -77,9 +77,6 @@ this.viewController = viewController; } - /// - /// Creates an - /// public void CreateAssessmentSectionFromFile() { if (!TryValidate()) Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IAssessmentSectionFromFileCommandHandler.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IAssessmentSectionFromFileCommandHandler.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IAssessmentSectionFromFileCommandHandler.cs (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -0,0 +1,39 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using Core.Common.Base.Data; +using Core.Common.Gui; +using Ringtoets.Integration.Data; + +namespace Ringtoets.Integration.Forms.Commands +{ + /// + /// Interface for exposing command related to adding an to an in the . + /// + public interface IAssessmentSectionFromFileCommandHandler + { + /// + /// Displays a dialog of objects. + /// If an is selected to import, it is added to the in the . + /// + void CreateAssessmentSectionFromFile(); + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -49,7 +49,9 @@ Properties\GlobalAssembly.cs + + Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -198,5 +198,23 @@ "d_0_", resourceCulture); } } + + /// + /// Looks up a localized string similar to Nieuw. + /// + public static string RingtoetsRibbon_GroupBox_New { + get { + return ResourceManager.GetString("RingtoetsRibbon_GroupBox_New", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Start. + /// + public static string RingtoetsRibbon_TabItem_View { + get { + return ResourceManager.GetString("RingtoetsRibbon_TabItem_View", resourceCulture); + } + } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -163,4 +163,10 @@ Opmerkingen + + Nieuw + + + Start + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r2227f1d3a31b15a6d05c5385898d5da4b79dcdea -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 2227f1d3a31b15a6d05c5385898d5da4b79dcdea) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -42,7 +42,6 @@ using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Probability; -using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TreeNodeInfos; @@ -200,13 +199,15 @@ #endregion - private AssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler; + private RingtoetsRibbon ribbonCommandHandler; + private IAssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler; + public override IRibbonCommandHandler RibbonCommandHandler { get { - return new RingtoetsRibbon(); + return ribbonCommandHandler; } } @@ -233,7 +234,11 @@ throw new InvalidOperationException("Gui cannot be null"); } assessmentSectionFromFileCommandHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow, Gui, Gui.DocumentViewController); - + + ribbonCommandHandler = new RingtoetsRibbon + { + AddAssessmentSectionButtonCommand = new AddAssessmentSectionCommand(assessmentSectionFromFileCommandHandler) + }; } /// @@ -703,12 +708,7 @@ #endregion #region AssessmentSection - - private static string GetUniqueForAssessmentSectionName(IEnumerable assessmentSections, string baseName) - { - return NamingHelper.GetUniqueName(assessmentSections, baseName, a => a.Name); - } - + private object[] AssessmentSectionChildNodeObjects(IAssessmentSection nodeData) { var childNodes = new List @@ -1020,7 +1020,6 @@ RestoreDirectory = true, CheckFileExists = false }) - { if (dialog.ShowDialog(Gui.MainWindow) == DialogResult.OK) { try @@ -1032,7 +1031,6 @@ log.Error(exception.Message, exception); } } - } } /// @@ -1058,7 +1056,6 @@ } using (var hydraulicBoundaryLocationsImporter = new HydraulicBoundaryDatabaseImporter()) - { if (hydraulicBoundaryLocationsImporter.Import(assessmentSection, databaseFile)) { if (isClearConfirmationGiven) @@ -1069,7 +1066,6 @@ log.InfoFormat(RingtoetsFormsResources.RingtoetsPlugin_SetBoundaryDatabaseFilePath_Database_on_path_0_linked, assessmentSection.HydraulicBoundaryDatabase.FilePath); } - } } private static bool IsClearCalculationConfirmationGiven() Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml =================================================================== diff -u -r1e08e4d88dc94cddaf7cbd38bdc2b42f263225bc -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml (.../RingtoetsRibbon.xaml) (revision 1e08e4d88dc94cddaf7cbd38bdc2b42f263225bc) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml (.../RingtoetsRibbon.xaml) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -4,11 +4,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent" + xmlns:Converters="clr-namespace:Core.Common.Gui.Converters;assembly=Core.Common.Gui" + xmlns:resx="clr-namespace:Ringtoets.Integration.Plugin.Properties" + xmlns:properties="clr-namespace:Ringtoets.Integration.Forms.Properties;assembly=Ringtoets.Integration.Forms" mc:Ignorable="d" Width="686.4" Height="168" Background="White"> - + - + + + + + Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml.cs =================================================================== diff -u -r64d5609bb2912cd52dc74deffdd189222e240599 -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml.cs (.../RingtoetsRibbon.xaml.cs) (revision 64d5609bb2912cd52dc74deffdd189222e240599) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsRibbon.xaml.cs (.../RingtoetsRibbon.xaml.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -20,6 +20,7 @@ // All rights reserved. using System.Collections.Generic; +using System.Windows; using Core.Common.Controls.Commands; using Core.Common.Gui.Forms; using Fluent; @@ -39,11 +40,19 @@ InitializeComponent(); } + /// + /// Sets the command used to control the add assessment section button. + /// + public ICommand AddAssessmentSectionButtonCommand { set; private get; } + public IEnumerable Commands { get { - yield break; + if (AddAssessmentSectionButtonCommand != null) + { + yield return AddAssessmentSectionButtonCommand; + } } } @@ -52,14 +61,18 @@ return RingtoetsRibbonControl; } - public void ValidateItems() - { - // Do nothing - } + public void ValidateItems() {} public bool IsContextualTabVisible(string tabGroupName, string tabName) { return false; } + + private void ButtonAddAssessmentSectionToolWindowClick(object sender, RoutedEventArgs e) + { + AddAssessmentSectionButtonCommand.Execute(); + + ValidateItems(); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AddAssessmentSectionCommandTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AddAssessmentSectionCommandTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AddAssessmentSectionCommandTest.cs (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Windows.Forms; +using Core.Common.Controls.Commands; +using Core.Common.Gui; +using Core.Common.Gui.Forms.ViewHost; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Integration.Forms.Commands; + +namespace Ringtoets.Integration.Forms.Test.Commands +{ + [TestFixture] + public class AddAssessmentSectionCommandTest + { + [Test] + public void Constructor_WithoutController_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new AddAssessmentSectionCommand(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_WithController_CreatesNewICommand() + { + // Setup + var mockRepository = new MockRepository(); + var window = mockRepository.StrictMock(); + var projectOwner = mockRepository.StrictMock(); + var documentViewController = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var commandHandler = new AssessmentSectionFromFileCommandHandler(window, projectOwner, documentViewController); + + // Call + var command = new AddAssessmentSectionCommand(commandHandler); + + // Assert + Assert.IsInstanceOf(command); + Assert.IsTrue(command.Enabled); + Assert.IsTrue(command.Checked); + mockRepository.VerifyAll(); + } + + [Test] + public void Execute_Always_CallsCreateAssessmentSectionFromFile() + { + // Setup + var mockRepository = new MockRepository(); + var commandHandler = mockRepository.StrictMock(); + commandHandler.Expect(ch => ch.CreateAssessmentSectionFromFile()); + mockRepository.ReplayAll(); + var command = new AddAssessmentSectionCommand(commandHandler); + + // Call + command.Execute(); + + // Assert + mockRepository.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs =================================================================== diff -u -r50b203a8d5c805fc548fb6b92c70a847190da6a5 -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (.../AssessmentSectionFromFileCommandHandlerTest.cs) (revision 50b203a8d5c805fc548fb6b92c70a847190da6a5) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (.../AssessmentSectionFromFileCommandHandlerTest.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -20,8 +20,6 @@ // All rights reserved. using System; -using System.Collections; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; @@ -61,6 +59,7 @@ // Assert var paramName = Assert.Throws(call).ParamName; Assert.AreEqual("dialogParent", paramName); + mockRepository.VerifyAll(); } [Test] @@ -78,6 +77,7 @@ // Assert var paramName = Assert.Throws(call).ParamName; Assert.AreEqual("projectOwner", paramName); + mockRepository.VerifyAll(); } [Test] @@ -95,9 +95,29 @@ // Assert var paramName = Assert.Throws(call).ParamName; Assert.AreEqual("viewController", paramName); + mockRepository.VerifyAll(); } [Test] + public void Constructor_WithData_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var parentDialogMock = mockRepository.StrictMock(); + var projectOwnerMock = mockRepository.StrictMock(); + var viewControllerMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + // Call + var assessmentSectionFromFileCommandHandler = + new AssessmentSectionFromFileCommandHandler(parentDialogMock, projectOwnerMock, viewControllerMock); + + // Assert + Assert.IsInstanceOf(assessmentSectionFromFileCommandHandler); + mockRepository.VerifyAll(); + } + + [Test] public void CreateAssessmentSectionFromFile_InvalidDirectory_LogsWarningProjectOwnerNotUpdated() { // Setup @@ -218,7 +238,7 @@ AssertAssessmentSection(TestAssessmentSection1_2(true), assessmentSection); mockRepository.VerifyAll(); } - + [Test] public void CreateAssessmentSectionFromFile_ValidDirectoryOkClickedForDuplicateAssessmentSection_SetsFirstReadAssessmentSectionWithUniqueName() { @@ -410,12 +430,13 @@ Assert.IsNotNull(assessmentSection); var expectedAssessmentSection = TestAssessmentSection1_2(true); - expectedAssessmentSection.ReferenceLine.SetGeometry(new Point2D[]{}); + expectedAssessmentSection.ReferenceLine.SetGeometry(new Point2D[] + {}); AssertAssessmentSection(expectedAssessmentSection, assessmentSection); mockRepository.VerifyAll(); } - + [Test] public void CreateAssessmentSectionFromFile_ShapeWithoutInvalidNormOkClicked_LogsAndSetsAssessmentSectionWithoutNorm() { Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r2227f1d3a31b15a6d05c5385898d5da4b79dcdea -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 2227f1d3a31b15a6d05c5385898d5da4b79dcdea) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -62,6 +62,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r2227f1d3a31b15a6d05c5385898d5da4b79dcdea -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 2227f1d3a31b15a6d05c5385898d5da4b79dcdea) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -71,7 +71,7 @@ { // Assert Assert.IsInstanceOf(plugin); - Assert.IsInstanceOf(plugin.RibbonCommandHandler); + Assert.IsNull(plugin.RibbonCommandHandler); } } @@ -469,6 +469,7 @@ } [Test] + [STAThread] // Due to creating fluent Ribbon public void Activate_WithGui_DoesNotThrowException() { // Setup @@ -491,6 +492,7 @@ // Assert Assert.DoesNotThrow(test); + Assert.IsInstanceOf(plugin.RibbonCommandHandler); } mockRepository.VerifyAll(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsRibbonTest.cs =================================================================== diff -u -r1e08e4d88dc94cddaf7cbd38bdc2b42f263225bc -r75c007324755a9f899f7fc5639ff873311343bdc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsRibbonTest.cs (.../RingtoetsRibbonTest.cs) (revision 1e08e4d88dc94cddaf7cbd38bdc2b42f263225bc) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsRibbonTest.cs (.../RingtoetsRibbonTest.cs) (revision 75c007324755a9f899f7fc5639ff873311343bdc) @@ -1,10 +1,32 @@ -using System; +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. +using System; +using System.Windows; +using System.Windows.Controls.Primitives; +using Core.Common.Controls.Commands; using Core.Common.Gui.Forms; - using Fluent; - using NUnit.Framework; +using Rhino.Mocks; namespace Ringtoets.Integration.Plugin.Test { @@ -50,5 +72,54 @@ // Assert Assert.IsFalse(isVisible); } + + [Test] + [RequiresSTA] + public void Commands_ToggleExplorerCommandSet_ReturnsToggleExplorerCommand() + { + // Setup + var mockRepository = new MockRepository(); + var command = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var ribbon = new RingtoetsRibbon + { + AddAssessmentSectionButtonCommand = command + }; + + // Call + var result = ribbon.Commands; + + // Assert + CollectionAssert.AreEqual(new[] { command }, result); + mockRepository.VerifyAll(); + } + + [Test] + [STAThread] // Due to creating fluent Ribbon + public void AddAssessmentSectionButtonCommand_AddAssessmentSectionButtonClicked_ExecutesCommand() + { + // Setup + var mockRepository = new MockRepository(); + var commandMock = mockRepository.StrictMock(); + commandMock.Expect(c => c.Execute()); + mockRepository.ReplayAll(); + + var ribbon = new RingtoetsRibbon + { + AddAssessmentSectionButtonCommand = commandMock + }; + + var addAssessmentSectionButton = ribbon.GetRibbonControl().FindName("AddAssessmentSectionButton") as Button; + + // Precondition + Assert.IsNotNull(addAssessmentSectionButton, "RingtoetsRibbon should have an add assessment section button."); + + // Call + addAssessmentSectionButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + mockRepository.VerifyAll(); + } } } \ No newline at end of file