Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContext.cs =================================================================== diff -u -r4f4daebe59ab925c98cef039101ec70544530bbe -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContext.cs (.../WaveImpactAsphaltCoverCalculationGroupContext.cs) (revision 4f4daebe59ab925c98cef039101ec70544530bbe) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContext.cs (.../WaveImpactAsphaltCoverCalculationGroupContext.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -32,21 +32,21 @@ /// Presentation object for all data required to configure an instance of /// in order be able to create configurable wave impact asphalt calculations. /// - public class WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext + public class WaveImpactAsphaltCoverCalculationGroupContext : WaveImpactAsphaltCoverContext, ICalculationContext { /// - /// Creates a new instance of . + /// Creates a new instance of . /// /// The instance wrapped by this context object. /// The that owns the wrapped calculation group. /// The failure mechanism which the context belongs to. /// The assessment section which the context belongs to. /// Thrown when any input argument is null, except for . - public WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(CalculationGroup calculationsGroup, - CalculationGroup parent, - WaveImpactAsphaltCoverFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) + public WaveImpactAsphaltCoverCalculationGroupContext(CalculationGroup calculationsGroup, + CalculationGroup parent, + WaveImpactAsphaltCoverFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) : base(calculationsGroup, failureMechanism, assessmentSection) { Parent = parent; @@ -57,13 +57,13 @@ public override bool Equals(WrappedObjectContextBase other) { return base.Equals(other) - && other is WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext - && ReferenceEquals(Parent, ((WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext) other).Parent); + && other is WaveImpactAsphaltCoverCalculationGroupContext + && ReferenceEquals(Parent, ((WaveImpactAsphaltCoverCalculationGroupContext) other).Parent); } public override bool Equals(object obj) { - return Equals(obj as WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext); + return Equals(obj as WaveImpactAsphaltCoverCalculationGroupContext); } public override int GetHashCode() Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r8c072e47f45c99aa325cb8d2e2d5dad3f4b43888 -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 8c072e47f45c99aa325cb8d2e2d5dad3f4b43888) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -142,7 +142,7 @@ public override IEnumerable GetImportInfos() { - yield return RiskeerImportInfoFactory.CreateCalculationConfigurationImportInfo( + yield return RiskeerImportInfoFactory.CreateCalculationConfigurationImportInfo( (context, filePath) => new WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationImporter( filePath, @@ -174,10 +174,10 @@ .Build() }; - yield return RiskeerTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo( - WaveConditionsCalculationGroupContextChildNodeObjects, - WaveConditionsCalculationGroupContextContextMenuStrip, - WaveConditionsCalculationGroupContextOnNodeRemoved); + yield return RiskeerTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo( + CalculationGroupContextChildNodeObjects, + CalculationGroupContextContextMenuStrip, + CalculationGroupContextOnNodeRemoved); yield return RiskeerTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo( WaveConditionsCalculationContextChildNodeObjects, @@ -218,7 +218,7 @@ public override IEnumerable GetExportInfos() { - yield return new ExportInfo + yield return new ExportInfo { Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName, Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension, @@ -248,7 +248,7 @@ GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), GetWaveConditionsFileFilterGenerator()) }; - yield return RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo( + yield return RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo( (context, filePath) => new WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationExporter( context.WrappedData.Children, filePath, context.AssessmentSection), context => context.WrappedData.Children.Any(), @@ -322,8 +322,8 @@ { new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetHydraulicLoadsInputs(failureMechanism, assessmentSection), TreeFolderCategory.Input), - new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup, null, - failureMechanism, assessmentSection) + new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, null, + failureMechanism, assessmentSection) }; } @@ -453,9 +453,9 @@ #endregion - #region WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext TreeNodeInfo + #region WaveImpactAsphaltCoverCalculationGroupContext TreeNodeInfo - private static object[] WaveConditionsCalculationGroupContextChildNodeObjects(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) + private static object[] CalculationGroupContextChildNodeObjects(WaveImpactAsphaltCoverCalculationGroupContext nodeData) { var childNodeObjects = new List(); @@ -473,10 +473,10 @@ } else if (group != null) { - childNodeObjects.Add(new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(group, - nodeData.WrappedData, - nodeData.FailureMechanism, - nodeData.AssessmentSection)); + childNodeObjects.Add(new WaveImpactAsphaltCoverCalculationGroupContext(group, + nodeData.WrappedData, + nodeData.FailureMechanism, + nodeData.AssessmentSection)); } else { @@ -487,14 +487,14 @@ return childNodeObjects.ToArray(); } - private ContextMenuStrip WaveConditionsCalculationGroupContextContextMenuStrip(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData, - object parentData, TreeViewControl treeViewControl) + private ContextMenuStrip CalculationGroupContextContextMenuStrip(WaveImpactAsphaltCoverCalculationGroupContext nodeData, + object parentData, TreeViewControl treeViewControl) { CalculationGroup group = nodeData.WrappedData; IInquiryHelper inquiryHelper = GetInquiryHelper(); var builder = new RiskeerContextMenuBuilder(Gui.Get(nodeData, treeViewControl)); - bool isNestedGroup = parentData is WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext; + bool isNestedGroup = parentData is WaveImpactAsphaltCoverCalculationGroupContext; WaveImpactAsphaltCoverWaveConditionsCalculation[] calculations = group .GetCalculations() @@ -555,24 +555,24 @@ .Build(); } - private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) + private StrictContextMenuItem CreateGenerateWaveConditionsCalculationsItem(WaveImpactAsphaltCoverCalculationGroupContext nodeData) { bool locationsAvailable = nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations.Any(); - string waveImpactAsphaltCoverWaveConditionsCalculationGroupContextToolTip = locationsAvailable - ? RiskeerCommonFormsResources.CalculationGroup_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip - : RiskeerCommonFormsResources.CalculationGroup_No_HydraulicBoundaryDatabase_To_Generate_ToolTip; + string calculationGroupContextToolTip = locationsAvailable + ? RiskeerCommonFormsResources.CalculationGroup_CreateGenerateHydraulicBoundaryCalculationsItem_ToolTip + : RiskeerCommonFormsResources.CalculationGroup_No_HydraulicBoundaryDatabase_To_Generate_ToolTip; return new StrictContextMenuItem(RiskeerCommonFormsResources.CalculationGroup_Generate_calculations, - waveImpactAsphaltCoverWaveConditionsCalculationGroupContextToolTip, + calculationGroupContextToolTip, RiskeerCommonFormsResources.GenerateScenariosIcon, (sender, args) => ShowHydraulicBoundaryLocationSelectionDialog(nodeData)) { Enabled = locationsAvailable }; } - private void ShowHydraulicBoundaryLocationSelectionDialog(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) + private void ShowHydraulicBoundaryLocationSelectionDialog(WaveImpactAsphaltCoverCalculationGroupContext nodeData) { using (var dialog = new HydraulicBoundaryLocationSelectionDialog(Gui.MainWindow, nodeData.AssessmentSection.HydraulicBoundaryDatabase.Locations)) { @@ -598,7 +598,7 @@ normType); } - private static void AddWaveConditionsCalculation(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData) + private static void AddWaveConditionsCalculation(WaveImpactAsphaltCoverCalculationGroupContext nodeData) { var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation { @@ -612,21 +612,21 @@ nodeData.WrappedData.NotifyObservers(); } - private static void WaveConditionsCalculationGroupContextOnNodeRemoved(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext nodeData, object parentNodeData) + private static void CalculationGroupContextOnNodeRemoved(WaveImpactAsphaltCoverCalculationGroupContext nodeData, object parentNodeData) { - var parentGroupContext = (WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext) parentNodeData; + var parentGroupContext = (WaveImpactAsphaltCoverCalculationGroupContext) parentNodeData; parentGroupContext.WrappedData.Children.Remove(nodeData.WrappedData); parentGroupContext.NotifyObservers(); } - private static string EnableValidateAndCalculateMenuItemForCalculationGroup(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext context) + private static string EnableValidateAndCalculateMenuItemForCalculationGroup(WaveImpactAsphaltCoverCalculationGroupContext context) { return EnableValidateAndCalculateMenuItem(context.AssessmentSection); } - private static void ValidateAllInCalculationGroup(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext context) + private static void ValidateAllInCalculationGroup(WaveImpactAsphaltCoverCalculationGroupContext context) { foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in context.WrappedData.GetCalculations().OfType()) { @@ -636,7 +636,7 @@ } } - private void CalculateAllInCalculationGroup(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext context) + private void CalculateAllInCalculationGroup(WaveImpactAsphaltCoverCalculationGroupContext context) { ActivityProgressDialogRunner.Run( Gui.MainWindow, @@ -730,7 +730,7 @@ private static void WaveConditionsCalculationContextOnNodeRemoved(WaveImpactAsphaltCoverWaveConditionsCalculationContext nodeData, object parentNodeData) { - if (parentNodeData is WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext calculationGroupContext) + if (parentNodeData is WaveImpactAsphaltCoverCalculationGroupContext calculationGroupContext) { bool successfullyRemovedData = calculationGroupContext.WrappedData.Children.Remove(nodeData.WrappedData); if (successfullyRemovedData) Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContextTest.cs =================================================================== diff -u -r4f4daebe59ab925c98cef039101ec70544530bbe -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContextTest.cs (.../WaveImpactAsphaltCoverCalculationGroupContextTest.cs) (revision 4f4daebe59ab925c98cef039101ec70544530bbe) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverCalculationGroupContextTest.cs (.../WaveImpactAsphaltCoverCalculationGroupContextTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -32,7 +32,7 @@ namespace Riskeer.WaveImpactAsphaltCover.Forms.Test.PresentationObjects { [TestFixture] - public class WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTest + public class WaveImpactAsphaltCoverCalculationGroupContextTest { [Test] [TestCase(true)] @@ -50,7 +50,7 @@ CalculationGroup parent = hasParent ? new CalculationGroup() : null; // Call - var groupContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, parent, failureMechanism, assessmentSection); + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, parent, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>(groupContext); @@ -65,9 +65,9 @@ [TestFixture(true)] [TestFixture(false)] - private class WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextEqualsTest - : EqualsTestFixture + private class WaveImpactAsphaltCoverCalculationGroupContextEqualsTest + : EqualsTestFixture { private static readonly MockRepository mocks = new MockRepository(); @@ -89,48 +89,48 @@ mocks.VerifyAll(); } - public WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextEqualsTest(bool hasParent) + public WaveImpactAsphaltCoverCalculationGroupContextEqualsTest(bool hasParent) { parent = hasParent ? new CalculationGroup() : null; } - protected override WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext CreateObject() + protected override WaveImpactAsphaltCoverCalculationGroupContext CreateObject() { - return new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, - parent, - failureMechanism, - assessmentSection); + return new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, + parent, + failureMechanism, + assessmentSection); } - protected override DerivedWaveImpactAsphaltCoverWaveConditionsCalculationGroupContext CreateDerivedObject() + protected override DerivedWaveImpactAsphaltCoverCalculationGroupContext CreateDerivedObject() { - return new DerivedWaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, - parent, - failureMechanism, - assessmentSection); + return new DerivedWaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, + parent, + failureMechanism, + assessmentSection); } private static IEnumerable GetUnequalTestCases() { - yield return new TestCaseData(new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(new CalculationGroup(), - parent, - failureMechanism, - assessmentSection)) + yield return new TestCaseData(new WaveImpactAsphaltCoverCalculationGroupContext(new CalculationGroup(), + parent, + failureMechanism, + assessmentSection)) .SetName("Wrapped Calculation Group"); - yield return new TestCaseData(new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(calculationGroup, - new CalculationGroup(), - failureMechanism, - assessmentSection)) + yield return new TestCaseData(new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, + new CalculationGroup(), + failureMechanism, + assessmentSection)) .SetName("Parent"); } } - private class DerivedWaveImpactAsphaltCoverWaveConditionsCalculationGroupContext : WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext + private class DerivedWaveImpactAsphaltCoverCalculationGroupContext : WaveImpactAsphaltCoverCalculationGroupContext { - public DerivedWaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(CalculationGroup calculationsGroup, - CalculationGroup parent, - WaveImpactAsphaltCoverFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) + public DerivedWaveImpactAsphaltCoverCalculationGroupContext(CalculationGroup calculationsGroup, + CalculationGroup parent, + WaveImpactAsphaltCoverFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) : base(calculationsGroup, parent, failureMechanism, assessmentSection) {} } } Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextConfigurationExportInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextConfigurationExportInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextConfigurationExportInfoTest.cs (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -0,0 +1,158 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.Forms.Main; +using Core.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Contribution; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.IO.Configurations; +using CoreGuiResources = Core.Gui.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.ExportInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverCalculationGroupContextConfigurationExportInfoTest + { + private WaveImpactAsphaltCoverPlugin plugin; + private ExportInfo info; + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + var mainWindow = mocks.Stub(); + var gui = mocks.Stub(); + gui.Stub(g => g.MainWindow).Return(mainWindow); + mocks.Replay(gui); + mocks.Replay(mainWindow); + + plugin = new WaveImpactAsphaltCoverPlugin + { + Gui = gui + }; + + info = plugin.GetExportInfos() + .Single(ei => ei.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext) + && ei.Name(null).Equals("Riskeer berekeningenconfiguratie")); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual("xml", info.Extension); + Assert.IsNotNull(info.CreateFileExporter); + Assert.IsNotNull(info.IsEnabled); + Assert.AreEqual("Algemeen", info.Category); + TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, info.Image); + Assert.IsNotNull(info.GetExportPath); + } + + [Test] + public void CreateFileExporter_Always_ReturnFileExporter() + { + // Setup + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(section => section.FailureMechanismContribution).Return(new FailureMechanismContribution(0.1, 0.1)); + mocks.ReplayAll(); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(new CalculationGroup(), + null, + new WaveImpactAsphaltCoverFailureMechanism(), + assessmentSection); + + // Call + IFileExporter fileExporter = info.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + + [Test] + public void IsEnabled_CalculationGroupNoChildren_ReturnFalse() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(new CalculationGroup(), + null, + new WaveImpactAsphaltCoverFailureMechanism(), + assessmentSection); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + + [Test] + [TestCase(true, false)] + [TestCase(false, true)] + public void IsEnabled_CalculationGroupWithChildren_ReturnTrue(bool hasNestedGroup, bool hasCalculation) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationGroup = new CalculationGroup(); + + if (hasNestedGroup) + { + calculationGroup.Children.Add(new CalculationGroup()); + } + + if (hasCalculation) + { + calculationGroup.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + } + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, + null, + new WaveImpactAsphaltCoverFailureMechanism(), + assessmentSection); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextWaveConditionsExportInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextWaveConditionsExportInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverCalculationGroupContextWaveConditionsExportInfoTest.cs (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -0,0 +1,201 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.Forms.Main; +using Core.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Revetment.Data.TestUtil; +using Riskeer.Revetment.IO.WaveConditions; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using CoreGuiResources = Core.Gui.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.ExportInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverCalculationGroupContextWaveConditionsExportInfoTest + { + private WaveImpactAsphaltCoverPlugin plugin; + private ExportInfo info; + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + var mainWindow = mocks.Stub(); + var gui = mocks.Stub(); + gui.Stub(g => g.MainWindow).Return(mainWindow); + mocks.Replay(gui); + mocks.Replay(mainWindow); + + plugin = new WaveImpactAsphaltCoverPlugin + { + Gui = gui + }; + + info = plugin.GetExportInfos() + .Single(ei => ei.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext) + && ei.Name(null).Equals("Berekende belastingen bij verschillende waterstanden")); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual("csv", info.Extension); + Assert.IsNotNull(info.CreateFileExporter); + Assert.IsNotNull(info.IsEnabled); + Assert.AreEqual("Algemeen", info.Category); + TestHelper.AssertImagesAreEqual(CoreGuiResources.ExportIcon, info.Image); + Assert.IsNotNull(info.GetExportPath); + } + + [Test] + public void CreateFileExporter_Always_ReturnFileExporter() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculationGroup = new CalculationGroup(); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection); + + // Call + IFileExporter fileExporter = info.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + + [Test] + public void IsEnabled_NoWaveImpactAsphaltCoverWaveConditionsCalculation_ReturnFalse() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculationGroup = new CalculationGroup(); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + + [Test] + [TestCase(true, TestName = "IsEnabled_WithOutput_ReturnExpectedEnabledState")] + [TestCase(false, TestName = "IsEnabled_WithoutOutput_ReturnExpectedEnabledState")] + public void IsEnabled_CalculationWithOrWithoutOutput_ReturnExpectedEnabledState(bool hasOutput) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculationGroup = new CalculationGroup(); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + + if (hasOutput) + { + var output = new[] + { + new TestWaveConditionsOutput() + }; + + calculation.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(output); + } + + calculationGroup.Children.Add(calculation); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.AreEqual(hasOutput, isEnabled); + } + + [Test] + [TestCase(true, TestName = "IsEnabled_WithOutputInSubFolder_ReturnExpectedEnabledState")] + [TestCase(false, TestName = "IsEnabled_WithoutOutputInSubFolder_ReturnExpectedEnabledState")] + public void IsEnabled_CalculationInSubFolder_ReturnExpectedEnabledState(bool hasOutput) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculationGroup = new CalculationGroup(); + + WaveImpactAsphaltCoverWaveConditionsOutput waveImpactAsphaltCoverWaveConditionsOutput = null; + if (hasOutput) + { + var output = new[] + { + new TestWaveConditionsOutput() + }; + waveImpactAsphaltCoverWaveConditionsOutput = new WaveImpactAsphaltCoverWaveConditionsOutput(output); + } + + calculationGroup.Children.Add( + new CalculationGroup + { + Children = + { + new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = waveImpactAsphaltCoverWaveConditionsOutput + } + } + }); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(calculationGroup, null, failureMechanism, assessmentSection); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.AreEqual(hasOutput, isEnabled); + } + } +} \ No newline at end of file Fisheye: Tag 8da89db9c186cedc26c4baa657f2dd8961877ec4 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextConfigurationExportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8da89db9c186cedc26c4baa657f2dd8961877ec4 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ExportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextWaveConditionsExportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ImportInfos/WaveImpactAsphaltCoverCalculationGroupContextImportInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ImportInfos/WaveImpactAsphaltCoverCalculationGroupContextImportInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ImportInfos/WaveImpactAsphaltCoverCalculationGroupContextImportInfoTest.cs (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -0,0 +1,136 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Drawing; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using Core.Common.Util; +using Core.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Properties; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.IO.Configurations; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.ImportInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverCalculationGroupContextImportInfoTest + { + private ImportInfo importInfo; + private WaveImpactAsphaltCoverPlugin plugin; + + [SetUp] + public void SetUp() + { + plugin = new WaveImpactAsphaltCoverPlugin(); + importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Name_Always_ReturnExpectedName() + { + // Call + string name = importInfo.Name; + + // Assert + Assert.AreEqual("Riskeer berekeningenconfiguratie", name); + } + + [Test] + public void Category_Always_ReturnExpectedCategory() + { + // Call + string category = importInfo.Category; + + // Assert + Assert.AreEqual("Algemeen", category); + } + + [Test] + public void Image_Always_ReturnExpectedIcon() + { + // Call + Image image = importInfo.Image; + + // Assert + TestHelper.AssertImagesAreEqual(Resources.GeneralFolderIcon, image); + } + + [Test] + public void FileFilterGenerator_Always_ReturnExpectedFileFilter() + { + // Call + FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; + + // Assert + Assert.AreEqual("Riskeer berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter); + } + + [Test] + public void IsEnabled_Always_ReturnTrue() + { + // Call + bool isEnabled = importInfo.IsEnabled(null); + + // Assert + Assert.IsTrue(isEnabled); + } + + [Test] + public void CreateFileImporter_Always_ReturnFileImporter() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + assessmentSection.Stub(section => section.WaterLevelCalculationsForUserDefinedTargetProbabilities) + .Return(new ObservableList()); + mocks.ReplayAll(); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(new CalculationGroup(), + null, + failureMechanism, + assessmentSection); + + // Call + IFileImporter importer = importInfo.CreateFileImporter(context, ""); + + // Assert + Assert.IsInstanceOf(importer); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag 8da89db9c186cedc26c4baa657f2dd8961877ec4 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ImportInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextImportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverCalculationGroupContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverCalculationGroupContextTreeNodeInfoTest.cs (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -0,0 +1,1947 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Controls.DataGrid; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.Commands; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.Main; +using Core.Gui.Plugin; +using Core.Gui.TestUtil; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Contribution; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms; +using Riskeer.Common.Service.TestUtil; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using Riskeer.Revetment.Data; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using CoreGuiResources = Core.Gui.Properties.Resources; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverCalculationGroupContextTreeNodeInfoTest : NUnitFormTest + { + private const int contextMenuImportConfigurationIndex = 0; + private const int contextMenuExportConfigurationIndex = 1; + + private const int contextMenuAddGenerateCalculationsIndex = 3; + private const int contextMenuAddCalculationGroupIndexRootGroup = 5; + private const int contextMenuAddCalculationIndexRootGroup = 6; + private const int contextMenuUpdateForeshoreProfileIndexRootGroup = 8; + private const int contextMenuValidateAllIndexRootGroup = 10; + private const int contextMenuCalculateAllIndexRootGroup = 11; + private const int contextMenuClearOutputIndexRootGroup = 13; + private const int contextMenuRemoveAllChildrenIndexRootGroup = 14; + private const int contextMenuCollapseAllIndexRootGroup = 16; + private const int contextMenuExpandAllIndexRootGroup = 17; + private const int contextMenuPropertiesIndexRootGroup = 19; + + private const int contextMenuDuplicateIndexNestedGroup = 3; + private const int contextMenuAddCalculationGroupIndexNestedGroup = 5; + private const int contextMenuAddCalculationIndexNestedGroup = 6; + private const int contextMenuUpdateForeshoreProfileIndexNestedGroup = 9; + private const int contextMenuValidateAllIndexNestedGroup = 11; + private const int contextMenuCalculateAllIndexNestedGroup = 12; + private const int contextMenuClearOutputIndexNestedGroup = 14; + + private IGui gui; + private MockRepository mocks; + private WaveImpactAsphaltCoverPlugin plugin; + private TreeNodeInfo info; + + private readonly string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Service, Path.Combine("HydraRingCalculation", "HRD ijsselmeer.sqlite")); + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNotNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNotNull(info.CanRename); + Assert.IsNotNull(info.OnNodeRenamed); + Assert.IsNotNull(info.CanRemove); + Assert.IsNotNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNotNull(info.CanDrag); + Assert.IsNotNull(info.CanDrop); + Assert.IsNotNull(info.CanInsert); + Assert.IsNotNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnGroupName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Hydraulische belastingen", text); + } + + [Test] + public void Image_Always_ReturnCalculationGroupIcon() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralFolderIcon, icon); + } + + [Test] + public void ChildNodeObjects_EmptyGroup_ReturnEmpty() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(groupContext); + + // Assert + CollectionAssert.IsEmpty(children); + } + + [Test] + public void ChildNodeObjects_GroupWithChildren_ReturnChildren() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var childGroup = new CalculationGroup(); + var calculationItem = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationItem); + failureMechanism.CalculationsGroup.Children.Add(childGroup); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(nodeData).ToArray(); + + // Assert + Assert.AreEqual(failureMechanism.CalculationsGroup.Children.Count, children.Length); + + var returnedCalculationContext = (WaveImpactAsphaltCoverWaveConditionsCalculationContext) children[0]; + Assert.AreSame(calculationItem, returnedCalculationContext.WrappedData); + Assert.AreSame(failureMechanism.CalculationsGroup, returnedCalculationContext.Parent); + Assert.AreSame(failureMechanism, returnedCalculationContext.FailureMechanism); + Assert.AreSame(assessmentSection, returnedCalculationContext.AssessmentSection); + + var returnedCalculationGroupContext = (WaveImpactAsphaltCoverCalculationGroupContext) children[1]; + Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); + Assert.AreSame(failureMechanism.CalculationsGroup, returnedCalculationGroupContext.Parent); + Assert.AreSame(failureMechanism, returnedCalculationGroupContext.FailureMechanism); + Assert.AreSame(assessmentSection, returnedCalculationGroupContext.AssessmentSection); + } + + [Test] + public void ContextMenuStrip_WithoutParentNodeDefaultBehavior_CallsContextMenuBuilderMethods() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + info.ContextMenuStrip(groupContext, null, treeViewControl); + } + + // Assert + // Assert expectancies called in TearDown() + } + + [Test] + public void ContextMenuStrip_WithoutParentNodeDefaultBehavior_AddCustomItems() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) + { + // Assert + Assert.AreEqual(20, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, + "Genereer &berekeningen...", + "Er is geen hydraulische belastingendatabase beschikbaar om de belastingenberekeningen te genereren.", + RiskeerCommonFormsResources.GenerateScenariosIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, + "&Map toevoegen", + "Voeg een nieuwe map toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.AddFolderIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.HydraulicCalculationIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateForeshoreProfileIndexRootGroup, + "&Bijwerken voorlandprofielen...", + "Er zijn geen berekeningen om bij te werken.", + RiskeerCommonFormsResources.UpdateItemIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_NestedCalculationGroup_CallsContextMenuBuilderMethods() + { + // Setup + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(group, + parentGroup, + failureMechanism, + assessmentSection); + var parentGroupContext = new WaveImpactAsphaltCoverCalculationGroupContext(parentGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddRenameItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddDeleteItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(cmp => cmp.Get(groupContext, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl); + } + + // Assert + // Assert expectancies called in TearDown() + } + + [Test] + public void ContextMenuStrip_NestedCalculationGroup_AddCustomItems() + { + // Setup + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var groupContext = new WaveImpactAsphaltCoverCalculationGroupContext(group, + parentGroup, + failureMechanism, + assessmentSection); + var parentGroupContext = new WaveImpactAsphaltCoverCalculationGroupContext(parentGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl)) + { + // Assert + Assert.AreEqual(21, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuDuplicateIndexNestedGroup, + "D&upliceren", + "Dupliceer dit element.", + RiskeerCommonFormsResources.CopyHS); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, + "&Map toevoegen", + "Voeg een nieuwe map toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.AddFolderIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexNestedGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.HydraulicCalculationIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateForeshoreProfileIndexNestedGroup, + "&Bijwerken voorlandprofielen...", + "Er zijn geen berekeningen om bij te werken.", + RiskeerCommonFormsResources.UpdateItemIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexNestedGroup, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexNestedGroup, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexNestedGroup, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_WithoutParentNodeWithoutHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var applicationFeatureCommandHandler = mocks.Stub(); + var importCommandHandler = mocks.StrictMock(); + importCommandHandler.Expect(ich => ich.GetSupportedImportInfos(nodeData)).Return(new[] + { + new ImportInfo() + }); + var exportCommandHandler = mocks.StrictMock(); + exportCommandHandler.Expect(ech => ech.CanExportFrom(nodeData)).Return(true); + var updateCommandHandler = mocks.StrictMock(); + var viewCommandsHandler = mocks.StrictMock(); + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, + importCommandHandler, + exportCommandHandler, + updateCommandHandler, + viewCommandsHandler, + nodeData, + treeViewControl); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuImportConfigurationIndex, + "&Importeren...", + "Importeer de gegevens vanuit een bestand.", + CoreGuiResources.ImportIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExportConfigurationIndex, + "&Exporteren...", + "Exporteer de gegevens naar een bestand.", + CoreGuiResources.ExportIcon); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, + "Genereer &berekeningen...", + "Er is geen hydraulische belastingendatabase beschikbaar om de belastingenberekeningen te genereren.", + RiskeerCommonFormsResources.GenerateScenariosIcon, false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, + "&Map toevoegen", + "Voeg een nieuwe map toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.AddFolderIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.HydraulicCalculationIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, + "Ma&p leegmaken...", + "Er zijn geen onderliggende elementen om te verwijderen.", + CoreGuiResources.DeleteChildrenIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, + "Alles i&nklappen", + "Klap dit element en alle onderliggende elementen in.", + CoreGuiResources.CollapseAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, + "Alles ui&tklappen", + "Klap dit element en alle onderliggende elementen uit.", + CoreGuiResources.ExpandAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, + "Ei&genschappen", + "Toon de eigenschappen in het Eigenschappenpaneel.", + CoreGuiResources.PropertiesHS, + false); + } + } + } + + [Test] + public void ContextMenuStrip_WithoutParentNodeWithHydraulicLocationsDefaultBehavior_ReturnContextMenuWithoutRenameRemove() + { + // Setup + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + { + Locations = + { + new TestHydraulicBoundaryLocation() + } + }); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var applicationFeatureCommandHandler = mocks.Stub(); + var importCommandHandler = mocks.StrictMock(); + importCommandHandler.Expect(ich => ich.GetSupportedImportInfos(nodeData)).Return(new[] + { + new ImportInfo() + }); + var exportCommandHandler = mocks.StrictMock(); + exportCommandHandler.Expect(ech => ech.CanExportFrom(nodeData)).Return(true); + var updateCommandHandler = mocks.StrictMock(); + var viewCommandsHandler = mocks.StrictMock(); + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, + importCommandHandler, + exportCommandHandler, + updateCommandHandler, + viewCommandsHandler, + nodeData, + treeViewControl); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuImportConfigurationIndex, + "&Importeren...", + "Importeer de gegevens vanuit een bestand.", + CoreGuiResources.ImportIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExportConfigurationIndex, + "&Exporteren...", + "Exporteer de gegevens naar een bestand.", + CoreGuiResources.ExportIcon); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, + "Genereer &berekeningen...", + "Genereer belastingenberekeningen.", + RiskeerCommonFormsResources.GenerateScenariosIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, + "&Map toevoegen", + "Voeg een nieuwe map toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.AddFolderIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.HydraulicCalculationIcon); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, + "Ma&p leegmaken...", + "Er zijn geen onderliggende elementen om te verwijderen.", + CoreGuiResources.DeleteChildrenIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearOutputIndexRootGroup, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, + "Alles ui&tklappen", + "Klap dit element en alle onderliggende elementen uit.", + CoreGuiResources.ExpandAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, + "Alles i&nklappen", + "Klap dit element en alle onderliggende elementen in.", + CoreGuiResources.CollapseAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, + "Ei&genschappen", + "Toon de eigenschappen in het Eigenschappenpaneel.", + CoreGuiResources.PropertiesHS, + false); + } + } + } + + [Test] + public void ContextMenuStrip_NestedCalculationGroupWithoutCalculations_CalculateAllAndValidateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + failureMechanism.CalculationsGroup.Children.Add(group); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er zijn geen berekeningen om uit te voeren.", calculateItem.ToolTipText); + Assert.AreEqual("Er zijn geen berekeningen om te valideren.", validateItem.ToolTipText); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_CalculateAllAndValidateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + failureMechanism.CalculationsGroup.Children.Add(group); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", calculateItem.ToolTipText); + Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", validateItem.ToolTipText); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_CalculateAllAndValidateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + failureMechanism.CalculationsGroup.Children.Add(group); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocks, "invalidFilePath"); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsFalse(validateItem.Enabled); + Assert.IsFalse(calculateItem.Enabled); + const string message = "Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. Fout bij het lezen van bestand 'invalidFilePath': het bestand bestaat niet."; + Assert.AreEqual(message, calculateItem.ToolTipText); + Assert.AreEqual(message, validateItem.ToolTipText); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_CalculateAllAndValidateAllEnabled() + { + // Setup + string validHydraulicBoundaryDatabasePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, + Path.Combine(nameof(HydraulicBoundaryDatabase), "complete.sqlite")); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validHydraulicBoundaryDatabasePath + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var group = new CalculationGroup(); + group.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + failureMechanism.CalculationsGroup.Children.Add(group); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Assert + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; + Assert.IsTrue(validateItem.Enabled); + Assert.IsTrue(calculateItem.Enabled); + Assert.AreEqual("Voer alle berekeningen binnen deze map met berekeningen uit.", calculateItem.ToolTipText); + Assert.AreEqual("Valideer alle berekeningen binnen deze map met berekeningen.", validateItem.ToolTipText); + } + } + } + + [Test] + public void ContextMenuStrip_TwoCalculationsClickOnValidateAllInGroup_ValidationMessagesLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); + + var group = new CalculationGroup(); + group.Children.Add(calculationA); + group.Children.Add(calculationB); + + failureMechanism.CalculationsGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(4, messages.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[2]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[3]); + }); + } + } + } + + [Test] + public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithCanUsePreprocessorFalse_NoValidationErrorsLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); + + var group = new CalculationGroup(); + group.Children.Add(calculation); + + failureMechanism.CalculationsGroup.Children.Add(group); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(2, messages.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]); + }); + } + } + } + + [Test] + public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorFalse_NoValidationErrorsLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); + + var group = new CalculationGroup(); + group.Children.Add(calculation); + + failureMechanism.CalculationsGroup.Children.Add(group); + + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = false; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "InvalidPreprocessorDirectory"; + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(2, messages.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]); + }); + } + } + } + + [Test] + public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_NoValidationErrorsLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First()); + + var group = new CalculationGroup(); + group.Children.Add(calculation); + + failureMechanism.CalculationsGroup.Children.Add(group); + + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = TestHelper.GetScratchPadPath(); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(2, messages.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[1]); + }); + } + } + } + + [Test] + public void ValidateAllViaContextMenuStrip_HydraulicBoundaryDatabaseWithUsePreprocessorTrue_ValidationErrorsLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(), + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0, + Orientation = (RoundedDouble) 0 + } + }; + + var group = new CalculationGroup(); + group.Children.Add(calculation); + + failureMechanism.CalculationsGroup.Children.Add(group); + + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.CanUsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessor = true; + assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.PreprocessorDirectory = "InvalidPreprocessorDirectory"; + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(3, messages.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messages[0]); + Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat is ongeldig. De bestandsmap bestaat niet.", messages[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messages[2]); + }); + } + } + } + + [Test] + public void ContextMenuStrip_TwoCalculationsClickOnCalculateAllInGroup_MessagesLogged() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + var observerA = mocks.StrictMock(); + observerA.Expect(o => o.UpdateObserver()); + var observerB = mocks.StrictMock(); + observerB.Expect(o => o.UpdateObserver()); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + + var group = new CalculationGroup(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(hydraulicBoundaryLocation); + calculationA.Name = "A"; + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(hydraulicBoundaryLocation); + calculationB.Name = "B"; + calculationA.Attach(observerA); + calculationB.Attach(observerB); + group.Children.Add(calculationA); + group.Children.Add(calculationB); + + failureMechanism.CalculationsGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mainWindow); + + int nrOfCalculators = failureMechanism.Calculations + .Cast() + .Sum(c => c.InputParameters.GetWaterLevels(WaveConditionsInputHelper.GetAssessmentLevel(c.InputParameters, assessmentSection)).Count()); + var calculatorFactory = mocks.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase), + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Times(nrOfCalculators); + mocks.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuCalculateAllIndexNestedGroup].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, m => + { + string[] messages = m.ToArray(); + Assert.AreEqual(30, messages.Length); + Assert.AreEqual("Golfcondities berekenen voor 'A' is gestart.", messages[0]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[3]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[13]); + Assert.AreEqual("Golfcondities berekenen voor 'A' is gelukt.", messages[14]); + + Assert.AreEqual("Golfcondities berekenen voor 'B' is gestart.", messages[15]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[18]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[28]); + Assert.AreEqual("Golfcondities berekenen voor 'B' is gelukt.", messages[29]); + }); + Assert.AreEqual(3, calculationA.Output.Items.Count()); + Assert.AreEqual(3, calculationB.Output.Items.Count()); + } + } + } + + [Test] + public void ContextMenuStrip_NoCalculations_ClearAllOutputItemDisabled() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, validFilePath); + + var group = new CalculationGroup(); + + failureMechanism.CalculationsGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + + var calculatorFactory = mocks.Stub(); + mocks.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + + // Assert + Assert.IsFalse(clearAllOutputItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_TwoCalculationsWithoutOutput_ClearAllOutputItemDisabled() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, validFilePath); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + + var group = new CalculationGroup(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(hydraulicBoundaryLocation); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(hydraulicBoundaryLocation); + group.Children.Add(calculationA); + group.Children.Add(calculationB); + + failureMechanism.CalculationsGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + + var calculatorFactory = mocks.Stub(); + mocks.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + ToolStripItem clearAllOutputItem = contextMenu.Items[contextMenuClearOutputIndexNestedGroup]; + + // Assert + Assert.IsFalse(clearAllOutputItem.Enabled); + } + } + } + + [Test] + [TestCase(true, TestName = "Menu_ClickClearAllOutput_ClearAllOutputAfterConfirmation(true)")] + [TestCase(false, TestName = "Menu_ClickClearAllOutput_ClearAllOutputAfterConfirmation(false)")] + public void ContextMenuStrip_TwoCalculationsWithOutputClickOnClearAllOutput_OutputRemovedForCalculationsAfterConfirmation(bool confirm) + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub( + failureMechanism, mocks, validFilePath); + + var observerA = mocks.StrictMock(); + var observerB = mocks.StrictMock(); + if (confirm) + { + observerA.Expect(o => o.UpdateObserver()); + observerB.Expect(o => o.UpdateObserver()); + } + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + + var group = new CalculationGroup(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(hydraulicBoundaryLocation); + calculationA.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(hydraulicBoundaryLocation); + calculationB.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()); + group.Children.Add(calculationA); + group.Children.Add(calculationB); + calculationA.Attach(observerA); + calculationB.Attach(observerB); + + failureMechanism.CalculationsGroup.Children.Add(group); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + DialogBoxHandler = (name, wnd) => + { + var dialog = new MessageBoxTester(wnd); + if (confirm) + { + dialog.ClickOk(); + } + else + { + dialog.ClickCancel(); + } + }; + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + + var calculatorFactory = mocks.Stub(); + mocks.ReplayAll(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Call + contextMenu.Items[contextMenuClearOutputIndexNestedGroup].PerformClick(); + + // Assert + if (confirm) + { + Assert.IsNull(calculationA.Output); + Assert.IsNull(calculationB.Output); + } + } + } + } + + [Test] + public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(group); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var calculationItem = new CalculationGroup + { + Name = "Nieuwe map" + }; + group.Children.Add(calculationItem); + + nodeData.Attach(observer); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + { + // Precondition + Assert.AreEqual(1, group.Children.Count); + + // Call + contextMenu.Items[contextMenuAddCalculationGroupIndexNestedGroup].PerformClick(); + + // Assert + Assert.AreEqual(2, group.Children.Count); + ICalculationBase newlyAddedItem = group.Children.Last(); + Assert.IsInstanceOf(newlyAddedItem); + Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + } + } + } + + [Test] + [TestCase(NormType.SignalFloodingProbability)] + [TestCase(NormType.MaximumAllowableFloodingProbability)] + public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers( + NormType normType) + { + // Setup + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = new AssessmentSectionStub + { + FailureMechanismContribution = + { + NormativeNorm = normType + } + }; + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + var calculationItem = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "Nieuwe berekening" + }; + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + group.Children.Add(calculationItem); + nodeData.Attach(observer); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Precondition + Assert.AreEqual(1, group.Children.Count); + + // Call + contextMenu.Items[contextMenuAddCalculationIndexRootGroup].PerformClick(); + + // Assert + Assert.AreEqual(2, group.Children.Count); + ICalculationBase newlyAddedItem = group.Children.Last(); + + var newCalculationItem = newlyAddedItem as WaveImpactAsphaltCoverWaveConditionsCalculation; + Assert.IsNotNull(newCalculationItem); + Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + Assert.AreEqual(GetWaterLevelTypeFromNormType(normType), newCalculationItem.InputParameters.WaterLevelType); + } + } + } + + [Test] + public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup() + { + // Given + var random = new Random(21); + var normType = random.NextEnumValue(); + + using (var treeViewControl = new TreeViewControl()) + { + var existingGroup = new CalculationGroup(); + var existingCalculation = new WaveImpactAsphaltCoverWaveConditionsCalculation(); + var group = new CalculationGroup + { + Children = + { + existingGroup, + existingCalculation + } + }; + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation(); + + var assessmentSection = new AssessmentSectionStub + { + FailureMechanismContribution = + { + NormativeNorm = normType + } + }; + assessmentSection.HydraulicBoundaryDatabase.Locations.AddRange(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var viewCommands = mocks.StrictMock(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + + mocks.ReplayAll(); + + nodeData.Attach(observer); + + HydraulicBoundaryLocationSelectionDialog dialog = null; + DataGridViewControl grid = null; + DialogBoxHandler = (name, wnd) => + { + dialog = (HydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject; + grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; + grid.Rows[0].Cells[0].Value = true; + grid.Rows[1].Cells[0].Value = true; + new ButtonTester("DoForSelectedButton", dialog).Click(); + }; + + // When + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); + + // Then + Assert.AreEqual(4, group.Children.Count); + Assert.AreSame(existingGroup, group.Children[0]); + Assert.AreSame(existingCalculation, group.Children[1]); + Assert.NotNull(dialog); + Assert.NotNull(grid); + + WaveConditionsInputWaterLevelType expectedWaveConditionsInputWaterLevelType = GetWaterLevelTypeFromNormType(normType); + var firstCalculation = group.Children[2] as WaveImpactAsphaltCoverWaveConditionsCalculation; + Assert.IsNotNull(firstCalculation); + WaveConditionsInput firstCalculationInput = firstCalculation.InputParameters; + Assert.AreSame(hydraulicBoundaryLocation1, firstCalculationInput.HydraulicBoundaryLocation); + Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, firstCalculationInput.WaterLevelType); + + var secondCalculation = group.Children[3] as WaveImpactAsphaltCoverWaveConditionsCalculation; + Assert.IsNotNull(secondCalculation); + WaveConditionsInput secondCalculationInput = secondCalculation.InputParameters; + Assert.AreSame(hydraulicBoundaryLocation2, secondCalculationInput.HydraulicBoundaryLocation); + Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, secondCalculationInput.WaterLevelType); + } + } + + [Test] + public void GivenDialogGenerateCalculationButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationGroupNotUpdated() + { + // Given + using (var treeViewControl = new TreeViewControl()) + { + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + { + Locations = + { + new TestHydraulicBoundaryLocation() + } + }); + + var observer = mocks.StrictMock(); + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var viewCommands = mocks.StrictMock(); + + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + + mocks.ReplayAll(); + + nodeData.Attach(observer); + + HydraulicBoundaryLocationSelectionDialog dialog = null; + DataGridViewControl grid = null; + DialogBoxHandler = (name, wnd) => + { + dialog = (HydraulicBoundaryLocationSelectionDialog) new FormTester(name).TheObject; + grid = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; + grid.Rows[0].Cells[0].Value = true; + new ButtonTester("CustomCancelButton", dialog).Click(); + }; + + // When + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); + + // Then + Assert.AreEqual(0, group.Children.Count); + Assert.NotNull(dialog); + Assert.NotNull(grid); + } + } + + [Test] + public void OnNodeRemoved_ParentIsCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers() + { + // Setup + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var group = new CalculationGroup(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext(group, + failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + + failureMechanism.CalculationsGroup.Children.Add(group); + var parentNodeData = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + parentNodeData.Attach(observer); + + // Precondition + Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); + + // Call + info.OnNodeRemoved(nodeData, parentNodeData); + + // Assert + CollectionAssert.DoesNotContain(failureMechanism.CalculationsGroup.Children, group); + } + + [Test] + public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + importHandler.Stub(ih => ih.GetSupportedImportInfos(context)).Return(Array.Empty()); + var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + updateHandler, + viewCommands, + context, + treeViewControl); + + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + // When + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Then + TestHelper.AssertContextMenuStripContainsItem(contextMenu, + contextMenuAddCalculationIndexRootGroup, + "Berekening &toevoegen", + "Voeg een nieuwe berekening toe aan deze map met berekeningen.", + RiskeerCommonFormsResources.HydraulicCalculationIcon); + } + } + } + + [Test] + public void GivenCalculationWithOutput_WhenClearingOutput_ThenClearOutput() + { + // Given + var observer = mocks.Stub(); + observer.Expect(o => o.UpdateObserver()); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.CalculationsGroup.Attach(observer); + + var context = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + new AssessmentSectionStub()); + + using (var treeViewControl = new TreeViewControl()) + { + var appFeatureCommandHandler = mocks.Stub(); + var importHandler = mocks.Stub(); + importHandler.Stub(ih => ih.GetSupportedImportInfos(context)).Return(Array.Empty()); + var exportHandler = mocks.Stub(); + var updateHandler = mocks.Stub(); + var viewCommands = mocks.Stub(); + var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler, + importHandler, + exportHandler, + updateHandler, + viewCommands, + context, + treeViewControl); + + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // When + ToolStripItem validateMenuItem = contextMenu.Items[contextMenuAddCalculationIndexRootGroup]; + validateMenuItem.PerformClick(); + + // Then + Assert.AreEqual(1, failureMechanism.CalculationsGroup.Children.Count); + Assert.IsInstanceOf(failureMechanism.CalculationsGroup.Children[0]); + // Check expectancies in TearDown() + } + } + } + + [Test] + public void ContextMenuStrip_CalculationGroupWithCalculationWithForeshoreProfileAndInputOutOfSync_ContextMenuItemUpdateForeshoreProfilesEnabledAndToolTipSet() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile() + } + }; + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext( + new CalculationGroup + { + Children = + { + calculation + } + }, + null, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + calculation.InputParameters.UseBreakWater = true; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, + contextMenuUpdateForeshoreProfileIndexRootGroup, + "&Bijwerken voorlandprofielen...", + "Alle berekeningen met een voorlandprofiel bijwerken.", + RiskeerCommonFormsResources.UpdateItemIcon); + } + } + } + + [Test] + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfilesClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + { + // Given + var calculationObserver = mocks.StrictMock(); + var calculationInputObserver = mocks.StrictMock(); + calculationInputObserver.Expect(o => o.UpdateObserver()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile(true) + } + }; + + var nodeData = new WaveImpactAsphaltCoverCalculationGroupContext( + new CalculationGroup + { + Children = + { + calculation + } + }, + null, + failureMechanism, + assessmentSection); + + calculation.Attach(calculationObserver); + calculation.InputParameters.Attach(calculationInputObserver); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + calculation.InputParameters.UseBreakWater = false; + + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenuStrip.Items[contextMenuUpdateForeshoreProfileIndexRootGroup].PerformClick(); + + // Then + Assert.IsTrue(calculation.InputParameters.IsForeshoreProfileInputSynchronized); + } + } + } + + public override void Setup() + { + mocks = new MockRepository(); + gui = mocks.Stub(); + plugin = new WaveImpactAsphaltCoverPlugin + { + Gui = gui + }; + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverCalculationGroupContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + + base.TearDown(); + } + + private IAssessmentSection CreateAssessmentSectionWithHydraulicBoundaryOutput() + { + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1300001, string.Empty, 0, 0); + + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = validFilePath, + Locations = + { + hydraulicBoundaryLocation + } + } + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase); + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + assessmentSection.WaterLevelCalculationsForLowerLimitNorm.First().Output = new TestHydraulicBoundaryLocationCalculationOutput(9.3); + + return assessmentSection; + } + + private static WaveImpactAsphaltCoverWaveConditionsCalculation GetValidCalculation(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + return new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability, + ForeshoreProfile = new TestForeshoreProfile(true), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + } + }; + } + + private static WaveConditionsInputWaterLevelType GetWaterLevelTypeFromNormType(NormType normType) + { + switch (normType) + { + case NormType.MaximumAllowableFloodingProbability: + return WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability; + case NormType.SignalFloodingProbability: + return WaveConditionsInputWaterLevelType.SignalFloodingProbability; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u -r8c072e47f45c99aa325cb8d2e2d5dad3f4b43888 -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs) (revision 8c072e47f45c99aa325cb8d2e2d5dad3f4b43888) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -177,7 +177,7 @@ var calculationsInputComments = (Comment) inputsFolder.Contents.ElementAt(1); Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments); - var hydraulicBoundariesCalculationGroup = (WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext) children[1]; + var hydraulicBoundariesCalculationGroup = (WaveImpactAsphaltCoverCalculationGroupContext) children[1]; Assert.AreSame(failureMechanism.CalculationsGroup, hydraulicBoundariesCalculationGroup.WrappedData); Assert.IsNull(hydraulicBoundariesCalculationGroup.Parent); Assert.AreSame(failureMechanism, hydraulicBoundariesCalculationGroup.FailureMechanism); Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r8c072e47f45c99aa325cb8d2e2d5dad3f4b43888 -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 8c072e47f45c99aa325cb8d2e2d5dad3f4b43888) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -330,10 +330,10 @@ failureMechanism, assessmentSection); - var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup, - null, - failureMechanism, - assessmentSection); + var parentContext = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); // Call bool canRemoveCalculation = info.CanRemove(context, parentContext); @@ -360,10 +360,10 @@ failureMechanism, assessmentSection); - var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup, - null, - failureMechanism, - assessmentSection); + var parentContext = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); // Call bool canRemoveCalculation = info.CanRemove(context, parentContext); @@ -394,10 +394,10 @@ failureMechanism, assessmentSection); - var parentContext = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.CalculationsGroup, - null, - failureMechanism, - assessmentSection); + var parentContext = new WaveImpactAsphaltCoverCalculationGroupContext(failureMechanism.CalculationsGroup, + null, + failureMechanism, + assessmentSection); // Call info.OnNodeRemoved(context, parentContext); Fisheye: Tag 8da89db9c186cedc26c4baa657f2dd8961877ec4 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs =================================================================== diff -u -r8c072e47f45c99aa325cb8d2e2d5dad3f4b43888 -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs) (revision 8c072e47f45c99aa325cb8d2e2d5dad3f4b43888) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -183,7 +183,7 @@ protected override ICalculationContext GetCalculationGroupContextWithCalculation() { - return new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext( + return new WaveImpactAsphaltCoverCalculationGroupContext( new CalculationGroup { Children = Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs =================================================================== diff -u -r3b838833901be7e334c406b2214e00341878f9c7 -r8da89db9c186cedc26c4baa657f2dd8961877ec4 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 3b838833901be7e334c406b2214e00341878f9c7) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) @@ -103,10 +103,10 @@ mockRepository.ReplayAll(); using (var plugin = new WaveImpactAsphaltCoverPlugin + { + Gui = gui + }) { - Gui = gui - }) - { // Call ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); @@ -159,7 +159,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverHydraulicLoadsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverFailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyWaveImpactAsphaltCoverOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsOutput))); @@ -178,16 +178,16 @@ mocks.ReplayAll(); using (var plugin = new WaveImpactAsphaltCoverPlugin + { + Gui = gui + }) { - Gui = gui - }) - { // Call ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert Assert.AreEqual(4, exportInfos.Length); - Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext))); + Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext))); Assert.AreEqual(2, exportInfos.Count(ei => ei.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext))); } @@ -205,7 +205,7 @@ // Assert Assert.AreEqual(1, importInfos.Length); - Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext))); + Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(WaveImpactAsphaltCoverCalculationGroupContext))); } }