Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneErosionCalculationsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneErosionHydraulicLoadsContext.cs =================================================================== diff -u --- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneErosionHydraulicLoadsContext.cs (revision 0) +++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneErosionHydraulicLoadsContext.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,44 @@ +// 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 Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.DuneErosion.Data; + +namespace Riskeer.DuneErosion.Forms.PresentationObjects +{ + /// + /// Presentation object for calculations of . + /// + public class DuneErosionHydraulicLoadsContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The instance + /// wrapped by this context object. + /// The assessment section which the failure mechanism belongs to. + /// Thrown when any parameter is null. + public DuneErosionHydraulicLoadsContext(DuneErosionFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs =================================================================== diff -u -rcff5afb73d16abe591f362d3ad26ebc59bfb8118 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision cff5afb73d16abe591f362d3ad26ebc59bfb8118) +++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -64,7 +64,7 @@ public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new DuneErosionCalculationsProperties(context.WrappedData, new DuneErosionFailureMechanismPropertyChangeHandler()) @@ -89,7 +89,7 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( CalculationsChildNodeObjects, CalculationsContextMenuStrip); @@ -141,7 +141,7 @@ (DuneErosionFailureMechanism) context.FailureMechanism) }; - yield return new ViewInfo + yield return new ViewInfo { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, @@ -250,7 +250,7 @@ .FirstOrDefault(); } - if (dataToCloseFor is DuneErosionCalculationsContext failureMechanismContext) + if (dataToCloseFor is DuneErosionHydraulicLoadsContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -264,7 +264,7 @@ #region DuneErosionCalculationsContext TreeNodeInfo - private static object[] CalculationsChildNodeObjects(DuneErosionCalculationsContext context) + private static object[] CalculationsChildNodeObjects(DuneErosionHydraulicLoadsContext context) { DuneErosionFailureMechanism wrappedData = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -285,7 +285,7 @@ }; } - private ContextMenuStrip CalculationsContextMenuStrip(DuneErosionCalculationsContext context, + private ContextMenuStrip CalculationsContextMenuStrip(DuneErosionHydraulicLoadsContext context, object parentData, TreeViewControl treeViewControl) { Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneErosionCalculationsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneErosionHydraulicLoadsContextTest.cs =================================================================== diff -u --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneErosionHydraulicLoadsContextTest.cs (revision 0) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneErosionHydraulicLoadsContextTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,54 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.DuneErosion.Data; +using Riskeer.DuneErosion.Forms.PresentationObjects; + +namespace Riskeer.DuneErosion.Forms.Test.PresentationObjects +{ + [TestFixture] + public class DuneErosionHydraulicLoadsContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new DuneErosionFailureMechanism(); + + // Call + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism, context.WrappedData); + Assert.AreSame(assessmentSection, context.Parent); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs =================================================================== diff -u -ra57e6b5e198e898a2cbfc3c35e50a3dfb25a55fe -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs (.../DuneErosionPluginTest.cs) (revision a57e6b5e198e898a2cbfc3c35e50a3dfb25a55fe) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs (.../DuneErosionPluginTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -77,7 +77,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(DuneErosionCalculationsContext), + typeof(DuneErosionHydraulicLoadsContext), typeof(DuneErosionCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, @@ -105,7 +105,7 @@ // Assert Assert.AreEqual(5, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneErosionCalculationsContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneErosionHydraulicLoadsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneErosionFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneLocationCalculationsGroupContext))); @@ -133,7 +133,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(DuneErosionCalculationsContext), + typeof(DuneErosionHydraulicLoadsContext), typeof(DuneErosionFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/PropertyInfos/DuneErosionCalculationsPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/PropertyInfos/DuneErosionHydraulicLoadsPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/PropertyInfos/DuneErosionHydraulicLoadsPropertyInfoTest.cs (revision 0) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/PropertyInfos/DuneErosionHydraulicLoadsPropertyInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,83 @@ +// 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.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.DuneErosion.Data; +using Riskeer.DuneErosion.Forms.PresentationObjects; +using Riskeer.DuneErosion.Forms.PropertyClasses; + +namespace Riskeer.DuneErosion.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class DuneErosionHydraulicLoadsPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new DuneErosionPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(DuneErosionHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(DuneErosionCalculationsProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new DuneErosionFailureMechanism(); + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new DuneErosionPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(DuneErosionPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(DuneErosionHydraulicLoadsContext)); + } + } +} \ No newline at end of file Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionCalculationsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,343 @@ +// 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.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.Main; +using Core.Gui.Forms.ViewHost; +using Core.Gui.TestUtil; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Plugin.TestUtil; +using Riskeer.Common.Service.TestUtil; +using Riskeer.DuneErosion.Data; +using Riskeer.DuneErosion.Data.TestUtil; +using Riskeer.DuneErosion.Forms.PresentationObjects; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.DuneErosion.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class DuneErosionHydraulicLoadsContextTreeNodeInfoTest + { + private const int contextMenuCalculateAllIndex = 2; + + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Forms, "HydraulicBoundaryDatabase"); + + private MockRepository mocksRepository; + private DuneErosionPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocksRepository = new MockRepository(); + plugin = new DuneErosionPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DuneErosionHydraulicLoadsContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + + mocksRepository.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocksRepository.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void ChildNodeObjects_WithContext_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + + var failureMechanism = new DuneErosionFailureMechanism(); + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(2, children.Length); + + var inputsFolder = (CategoryTreeFolder) children[0]; + Assert.AreEqual("Invoer", inputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); + + Assert.AreEqual(1, inputsFolder.Contents.Count()); + var inputComment = (Comment) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism.InputComments, inputComment); + + var duneLocationCalculationsGroupContext = (DuneLocationCalculationsGroupContext) children[1]; + Assert.AreSame(failureMechanism.DuneLocations, duneLocationCalculationsGroupContext.WrappedData); + Assert.AreSame(failureMechanism, duneLocationCalculationsGroupContext.FailureMechanism); + Assert.AreSame(assessmentSection, duneLocationCalculationsGroupContext.AssessmentSection); + } + + [Test] + public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() + { + // Setup + var failureMechanism = new DuneErosionFailureMechanism(); + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + var orderMocksRepository = new MockRepository(); + var menuBuilder = orderMocksRepository.StrictMock(); + using (orderMocksRepository.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).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.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); + } + + orderMocksRepository.ReplayAll(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + orderMocksRepository.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var duneLocation = new TestDuneLocation("Test"); + var failureMechanism = new DuneErosionFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + + failureMechanism.SetDuneLocations(new[] + { + duneLocation + }); + + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er is geen hydraulische belastingendatabase geïmporteerd.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_NoDuneLocationsPresent_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new DuneErosionFailureMechanism(); + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite") + } + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase); + + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + var mocks = new MockRepository(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Geen van de locaties is geschikt voor een hydraulische belastingenberekening.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + + mocks.VerifyAll(); + } + + [Test] + public void GivenValidCalculations_WhenCalculatingAllFromContextMenu_ThenAllCalculationsScheduled() + { + // Given + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite") + } + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase); + + var failureMechanism = new DuneErosionFailureMechanism + { + Contribution = 5 + }; + + var duneLocation = new TestDuneLocation("Test"); + failureMechanism.SetDuneLocations(new[] + { + duneLocation + }); + + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocksRepository); + gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.DocumentViewController).Return(mocksRepository.Stub()); + + var calculatorFactory = mocksRepository.Stub(); + var dunesBoundaryConditionsCalculator = new TestDunesBoundaryConditionsCalculator + { + Converged = false + }; + + calculatorFactory.Expect(cf => cf.CreateDunesBoundaryConditionsCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase), + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(dunesBoundaryConditionsCalculator).Repeat.Times(5); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // When + Action call = () => contextMenuAdapter.Items[contextMenuCalculateAllIndex].PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(40, msgs.Length); + + const string calculationTypeDisplayName = "Hydraulische belastingen"; + const string calculationDisplayName = "Hydraulische belastingenberekening"; + + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + duneLocation.Name, calculationTypeDisplayName, calculationDisplayName, "Iv", msgs, 0); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + duneLocation.Name, calculationTypeDisplayName, calculationDisplayName, "IIv", msgs, 8); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + duneLocation.Name, calculationTypeDisplayName, calculationDisplayName, "IIIv", msgs, 16); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + duneLocation.Name, calculationTypeDisplayName, calculationDisplayName, "IVv", msgs, 24); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + duneLocation.Name, calculationTypeDisplayName, calculationDisplayName, "Vv", msgs, 32); + }); + } + } + } + } +} \ No newline at end of file Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneErosionFailureMechanismViewInfoTest.cs =================================================================== diff -u -ra57e6b5e198e898a2cbfc3c35e50a3dfb25a55fe -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneErosionFailureMechanismViewInfoTest.cs (.../DuneErosionFailureMechanismViewInfoTest.cs) (revision a57e6b5e198e898a2cbfc3c35e50a3dfb25a55fe) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneErosionFailureMechanismViewInfoTest.cs (.../DuneErosionFailureMechanismViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -60,8 +60,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(DuneErosionCalculationsContext), info.DataType); - Assert.AreEqual(typeof(DuneErosionCalculationsContext), info.ViewDataType); + Assert.AreEqual(typeof(DuneErosionHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(DuneErosionHydraulicLoadsContext), info.ViewDataType); TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, info.Image); } @@ -73,7 +73,7 @@ mocks.ReplayAll(); var failureMechanism = new DuneErosionFailureMechanism(); - var context = new DuneErosionCalculationsContext(failureMechanism, assessmentSection); + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -91,7 +91,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new DuneErosionFailureMechanism(); - var context = new DuneErosionCalculationsContext(failureMechanism, assessmentSection); + var context = new DuneErosionHydraulicLoadsContext(failureMechanism, assessmentSection); using (var testForm = new Form()) { Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneLocationCalculationsViewInfoTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneLocationCalculationsViewInfoTest.cs (.../DuneLocationCalculationsViewInfoTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ViewInfos/DuneLocationCalculationsViewInfoTest.cs (.../DuneLocationCalculationsViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -338,7 +338,7 @@ var failureMechanism = new DuneErosionFailureMechanism(); - var context = new DuneErosionCalculationsContext( + var context = new DuneErosionHydraulicLoadsContext( failureMechanism, assessmentSection); @@ -377,7 +377,7 @@ }); mocks.ReplayAll(); - var context = new DuneErosionCalculationsContext( + var context = new DuneErosionHydraulicLoadsContext( new DuneErosionFailureMechanism(), assessmentSectionB); Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsCalculationsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContext.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContext.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContext.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,45 @@ +// 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 Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Data; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects +{ + /// + /// Presentation object for calculations of . + /// + public class GrassCoverErosionOutwardsHydraulicLoadsContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The + /// instance wrapped by this context object. + /// The assessment section which the failure mechanism belongs to. + /// Thrown when any parameter is null. + public GrassCoverErosionOutwardsHydraulicLoadsContext(GrassCoverErosionOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -rb9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision b9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -78,7 +78,7 @@ public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new GrassCoverErosionOutwardsCalculationsProperties( context.WrappedData, @@ -155,7 +155,7 @@ public override IEnumerable GetViewInfos() { - yield return new ViewInfo + yield return new ViewInfo { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, @@ -236,7 +236,7 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( CalculationsChildNodeObjects, CalculationsContextMenuStrip); @@ -453,7 +453,7 @@ return ReferenceEquals(assessmentSection, view.AssessmentSection); } - if (dataToCloseFor is GrassCoverErosionOutwardsCalculationsContext calculationsContext) + if (dataToCloseFor is GrassCoverErosionOutwardsHydraulicLoadsContext calculationsContext) { return ReferenceEquals(calculationsContext.WrappedData, view.AssessmentSection .GetFailureMechanisms() @@ -470,7 +470,7 @@ #region GrassCoverErosionOutwardsCalculationsContext TreeNodeInfo - private static object[] CalculationsChildNodeObjects(GrassCoverErosionOutwardsCalculationsContext context) + private static object[] CalculationsChildNodeObjects(GrassCoverErosionOutwardsHydraulicLoadsContext context) { GrassCoverErosionOutwardsFailureMechanism failureMechanism = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -493,7 +493,7 @@ }; } - private ContextMenuStrip CalculationsContextMenuStrip(GrassCoverErosionOutwardsCalculationsContext context, + private ContextMenuStrip CalculationsContextMenuStrip(GrassCoverErosionOutwardsHydraulicLoadsContext context, object parentData, TreeViewControl treeViewControl) { Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsCalculationsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContextTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContextTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsHydraulicLoadsContextTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,54 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PresentationObjects +{ + [TestFixture] + public class GrassCoverErosionOutwardsHydraulicLoadsContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(assessmentSection, context.Parent); + Assert.AreSame(failureMechanism, context.WrappedData); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -rede6ffb8684e6df841c3cae0c91b725abce8ed67 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision ede6ffb8684e6df841c3cae0c91b725abce8ed67) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -71,7 +71,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(GrassCoverErosionOutwardsCalculationsContext), + typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), typeof(GrassCoverErosionOutwardsFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( @@ -116,7 +116,7 @@ // Assert Assert.AreEqual(13, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsCalculationsContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsHydraulicLoadsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionOutwardsHydraulicBoundaryDatabaseContext))); @@ -146,7 +146,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(GrassCoverErosionOutwardsCalculationsContext), + typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), typeof(GrassCoverErosionOutwardsCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsHydraulicLoadsContextPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsHydraulicLoadsContextPropertyInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsHydraulicLoadsContextPropertyInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,83 @@ +// 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.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsHydraulicLoadsContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsCalculationsProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(GrassCoverErosionOutwardsHydraulicLoadsContext)); + } + } +} \ No newline at end of file Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsCalculationsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsHydraulicLoadsContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsHydraulicLoadsContextTreeNodeInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,494 @@ +// 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.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.Main; +using Core.Gui.Forms.ViewHost; +using Core.Gui.TestUtil; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Plugin.TestUtil; +using Riskeer.Common.Service.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Data.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using Riskeer.Revetment.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsHydraulicLoadsContextTreeNodeInfoTest + { + private const int contextMenuCalculateAllIndex = 2; + private MockRepository mocks; + private GrassCoverErosionOutwardsPlugin plugin; + private TreeNodeInfo info; + + private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Forms, "HydraulicBoundaryDatabase"); + private static readonly string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new GrassCoverErosionOutwardsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsHydraulicLoadsContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_WithContext_ReturnName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual(failureMechanism.Name, nodeText); + } + + [Test] + public void ForeColor_Always_ReturnControlText() + { + // Setup + mocks.ReplayAll(); + + // Call + Color foreColor = info.ForeColor(null); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); + } + + [Test] + public void Image_Always_ReturnFailureMechanismIcon() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, icon); + } + + [Test] + public void ChildNodeObjects_WithContext_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(2, children.Length); + var inputsFolder = (CategoryTreeFolder) children[0]; + Assert.AreEqual("Invoer", inputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); + + Assert.AreEqual(2, inputsFolder.Contents.Count()); + var foreshoreProfilesContext = (ForeshoreProfilesContext) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism.ForeshoreProfiles, foreshoreProfilesContext.WrappedData); + Assert.AreSame(failureMechanism, foreshoreProfilesContext.ParentFailureMechanism); + Assert.AreSame(assessmentSection, foreshoreProfilesContext.ParentAssessmentSection); + + var inputComment = (Comment) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.InputComments, inputComment); + + var hydraulicBoundaryDatabaseContext = (GrassCoverErosionOutwardsHydraulicBoundaryDatabaseContext) children[1]; + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryDatabaseContext.WrappedData); + Assert.AreSame(failureMechanism, hydraulicBoundaryDatabaseContext.FailureMechanism); + Assert.AreSame(assessmentSection, hydraulicBoundaryDatabaseContext.AssessmentSection); + } + + [Test] + public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).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.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); + } + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Voer alle berekeningen binnen dit toetsspoor uit.", + RiskeerCommonFormsResources.CalculateAllIcon); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Test"); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub(); + + failureMechanism.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation + }); + + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; + + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Er is geen hydraulische belastingendatabase geïmporteerd.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void GivenValidCalculations_WhenCalculatingAllFromContextMenu_ThenAllCalculationsScheduled() + { + // Given + var assessmentSection = new AssessmentSectionStub + { + HydraulicBoundaryDatabase = + { + FilePath = validFilePath + } + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 5 + }; + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Test"); + GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.SetHydraulicBoundaryLocations( + failureMechanism, assessmentSection, new[] + { + hydraulicBoundaryLocation + }); + + GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(hydraulicBoundaryLocation); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); + + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks); + + var gui = mocks.Stub(); + gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.DocumentViewController).Return(mocks.Stub()); + + var calculatorFactory = mocks.Stub(); + var designWaterLevelCalculator = new TestDesignWaterLevelCalculator + { + Converged = false, + DesignWaterLevel = 2.0 + }; + var waveHeightCalculator = new TestWaveHeightCalculator + { + Converged = false + }; + var waveConditionsCalculator = new TestWaveConditionsCosineCalculator + { + Converged = false + }; + + HydraulicBoundaryCalculationSettings expectedCalculationSettings = HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase); + calculatorFactory.Expect(cf => cf.CreateDesignWaterLevelCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + expectedCalculationSettings, + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(designWaterLevelCalculator) + .Repeat + .Times(5); + calculatorFactory.Expect(cf => cf.CreateWaveHeightCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + expectedCalculationSettings, + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(waveHeightCalculator) + .Repeat + .Times(5); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + expectedCalculationSettings, + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(waveConditionsCalculator) + .Repeat + .Times(6); + mocks.ReplayAll(); + + plugin.Gui = gui; + plugin.Activate(); + + using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // When + Action call = () => contextMenuAdapter.Items[contextMenuCalculateAllIndex].PerformClick(); + + // Then + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(108, msgs.Length); + + const string designWaterLevelCalculationTypeDisplayName = "Waterstand"; + const string designWaterLevelCalculationDisplayName = "Waterstand berekening"; + + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName, "Iv", msgs, 0); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName, "IIv", msgs, 8); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName, "IIIv", msgs, 16); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName, "IVv", msgs, 24); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, designWaterLevelCalculationTypeDisplayName, designWaterLevelCalculationDisplayName, "Vv", msgs, 32); + + const string waveHeightCalculationTypeDisplayName = "Golfhoogte"; + const string waveHeightCalculationDisplayName = "Golfhoogte berekening"; + + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName, "Iv", msgs, 40); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName, "IIv", msgs, 48); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName, "IIIv", msgs, 56); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName, "IVv", msgs, 64); + HydraulicBoundaryLocationCalculationActivityLogTestHelper.AssertHydraulicBoundaryLocationCalculationMessages( + hydraulicBoundaryLocation.Name, waveHeightCalculationTypeDisplayName, waveHeightCalculationDisplayName, "Vv", msgs, 72); + + Assert.AreEqual($"Golfcondities berekenen voor '{calculation.Name}' is gestart.", msgs.ElementAt(80)); + CalculationServiceTestHelper.AssertValidationStartMessage(msgs.ElementAt(81)); + CalculationServiceTestHelper.AssertValidationEndMessage(msgs.ElementAt(82)); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs.ElementAt(83)); + + IEnumerable waterLevels = calculation.InputParameters.GetWaterLevels( + failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.Single().Output.Result); + Assert.AreEqual(3, waterLevels.Count()); + AssertWaveConditionsCalculationMessages(msgs, waterLevels, "golfoploop", 84); + AssertWaveConditionsCalculationMessages(msgs, waterLevels, "golfklap", 95); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs.ElementAt(106)); + Assert.AreEqual($"Golfcondities berekenen voor '{calculation.Name}' is gelukt.", msgs.ElementAt(107)); + }); + } + } + } + + private static void AssertWaveConditionsCalculationMessages(string[] logMessages, IEnumerable waterLevels, string calculationType, int index) + { + Assert.AreEqual($"Berekening voor {calculationType} is gestart.", logMessages[index++]); + + foreach (RoundedDouble waterLevel in waterLevels) + { + Assert.AreEqual($"Berekening voor waterstand '{waterLevel}' is gestart.", logMessages[index++]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", logMessages[index++]); + Assert.AreEqual($"Berekening voor waterstand '{waterLevel}' is beëindigd.", logMessages[index++]); + } + + Assert.AreEqual($"Berekening voor {calculationType} is beëindigd.", logMessages[index]); + } + + private static GrassCoverErosionOutwardsWaveConditionsCalculation CreateValidCalculation(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + return new GrassCoverErosionOutwardsWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + CategoryType = FailureMechanismCategoryType.MechanismSpecificFactorizedSignalingNorm, + ForeshoreProfile = new TestForeshoreProfile(true) + { + BreakWater = + { + Height = new Random(39).NextRoundedDouble() + } + }, + UseForeshore = true, + UseBreakWater = true, + LowerBoundaryRevetment = (RoundedDouble) 1, + UpperBoundaryRevetment = (RoundedDouble) 2, + LowerBoundaryWaterLevels = (RoundedDouble) 1, + UpperBoundaryWaterLevels = (RoundedDouble) 2 + } + }; + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs =================================================================== diff -u -rb9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs) (revision b9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelCalculationsViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -299,7 +299,7 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - var context = new GrassCoverErosionOutwardsCalculationsContext( + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext( failureMechanism, assessmentSection); using (var view = new DesignWaterLevelCalculationsView(new ObservableList(), @@ -339,7 +339,7 @@ }); mocks.ReplayAll(); - var context = new GrassCoverErosionOutwardsCalculationsContext( + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext( new GrassCoverErosionOutwardsFailureMechanism(), assessmentSectionB); Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsFailureMechanismViewInfoTest.cs =================================================================== diff -u -rede6ffb8684e6df841c3cae0c91b725abce8ed67 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewInfoTest.cs) (revision ede6ffb8684e6df841c3cae0c91b725abce8ed67) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -61,8 +61,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(GrassCoverErosionOutwardsCalculationsContext), info.DataType); - Assert.AreEqual(typeof(GrassCoverErosionOutwardsCalculationsContext), info.ViewDataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), info.ViewDataType); } [Test] @@ -73,7 +73,7 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new GrassCoverErosionOutwardsCalculationsContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -100,7 +100,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new GrassCoverErosionOutwardsCalculationsContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); using (var testForm = new Form()) { Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveConditionsInputViewInfoTest.cs =================================================================== diff -u -rdd0a175348c628645d2dc498994c6d21c214d813 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveConditionsInputViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputViewInfoTest.cs) (revision dd0a175348c628645d2dc498994c6d21c214d813) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveConditionsInputViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsInputViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -204,7 +204,7 @@ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - return new GrassCoverErosionOutwardsCalculationsContext( + return new GrassCoverErosionOutwardsHydraulicLoadsContext( new GrassCoverErosionOutwardsFailureMechanism { WaveConditionsCalculationGroup = Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs =================================================================== diff -u -rb9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs) (revision b9ca1ec4ebea6d4cf89d7ae5d18477e7fa34629b) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightCalculationsViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -287,7 +287,7 @@ assessmentSection.Stub(a => a.Detach(null)).IgnoreArguments(); mocks.ReplayAll(); - var context = new GrassCoverErosionOutwardsCalculationsContext( + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext( failureMechanism, assessmentSection); using (var view = new WaveHeightCalculationsView(new ObservableList(), @@ -327,7 +327,7 @@ }); mocks.ReplayAll(); - var context = new GrassCoverErosionOutwardsCalculationsContext( + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext( new GrassCoverErosionOutwardsFailureMechanism(), assessmentSectionB); Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r063a29732e7d0ab9e61190474ecfec86c49a7c56 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 063a29732e7d0ab9e61190474ecfec86c49a7c56) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -1663,10 +1663,10 @@ return new object[] { new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection), - new StabilityStoneCoverCalculationsContext(assessmentSection.StabilityStoneCover, assessmentSection), - new WaveImpactAsphaltCoverCalculationsContext(assessmentSection.WaveImpactAsphaltCover, assessmentSection), - new GrassCoverErosionOutwardsCalculationsContext(assessmentSection.GrassCoverErosionOutwards, assessmentSection), - new DuneErosionCalculationsContext(assessmentSection.DuneErosion, assessmentSection) + new StabilityStoneCoverHydraulicLoadsContext(assessmentSection.StabilityStoneCover, assessmentSection), + new WaveImpactAsphaltCoverHydraulicLoadsContext(assessmentSection.WaveImpactAsphaltCover, assessmentSection), + new GrassCoverErosionOutwardsHydraulicLoadsContext(assessmentSection.GrassCoverErosionOutwards, assessmentSection), + new DuneErosionHydraulicLoadsContext(assessmentSection.DuneErosion, assessmentSection) }; } Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs =================================================================== diff -u -rcaf0cf2ad118a5ea9f0109176cbe31b94591f31e -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs (.../HydraulicLoadsStateRootContextTreeNodeInfoTest.cs) (revision caf0cf2ad118a5ea9f0109176cbe31b94591f31e) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/HydraulicLoadsStateRootContextTreeNodeInfoTest.cs (.../HydraulicLoadsStateRootContextTreeNodeInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -168,19 +168,19 @@ Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryDatabaseContext.WrappedData); Assert.AreSame(assessmentSection, hydraulicBoundaryDatabaseContext.AssessmentSection); - var stabilityStoneCoverHydraulicLoadsContext = (StabilityStoneCoverCalculationsContext) objects[1]; + var stabilityStoneCoverHydraulicLoadsContext = (StabilityStoneCoverHydraulicLoadsContext) objects[1]; Assert.AreSame(assessmentSection.StabilityStoneCover, stabilityStoneCoverHydraulicLoadsContext.WrappedData); Assert.AreSame(assessmentSection, stabilityStoneCoverHydraulicLoadsContext.Parent); - var waveImpactAsphaltCoverHydraulicLoadsContext = (WaveImpactAsphaltCoverCalculationsContext) objects[2]; + var waveImpactAsphaltCoverHydraulicLoadsContext = (WaveImpactAsphaltCoverHydraulicLoadsContext) objects[2]; Assert.AreSame(assessmentSection.WaveImpactAsphaltCover, waveImpactAsphaltCoverHydraulicLoadsContext.WrappedData); Assert.AreSame(assessmentSection, waveImpactAsphaltCoverHydraulicLoadsContext.Parent); - var grassCoverErosionOutwardsHydraulicLoadsContext = (GrassCoverErosionOutwardsCalculationsContext) objects[3]; + var grassCoverErosionOutwardsHydraulicLoadsContext = (GrassCoverErosionOutwardsHydraulicLoadsContext) objects[3]; Assert.AreSame(assessmentSection.GrassCoverErosionOutwards, grassCoverErosionOutwardsHydraulicLoadsContext.WrappedData); Assert.AreSame(assessmentSection, grassCoverErosionOutwardsHydraulicLoadsContext.Parent); - var duneErosionHydraulicLoadsContext = (DuneErosionCalculationsContext) objects[4]; + var duneErosionHydraulicLoadsContext = (DuneErosionHydraulicLoadsContext) objects[4]; Assert.AreSame(assessmentSection.DuneErosion, duneErosionHydraulicLoadsContext.WrappedData); Assert.AreSame(assessmentSection, duneErosionHydraulicLoadsContext.Parent); Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverCalculationsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverHydraulicLoadsContext.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverHydraulicLoadsContext.cs (revision 0) +++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PresentationObjects/StabilityStoneCoverHydraulicLoadsContext.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,43 @@ +// 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 Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.StabilityStoneCover.Data; + +namespace Riskeer.StabilityStoneCover.Forms.PresentationObjects +{ + /// + /// Presentation object for calculations of . + /// + public class StabilityStoneCoverHydraulicLoadsContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism. + /// The parent of . + /// Thrown when any parameter is null. + public StabilityStoneCoverHydraulicLoadsContext(StabilityStoneCoverFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) + : base(wrappedFailureMechanism, parent) {} + } +} \ No newline at end of file Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -rf5503aa2bc6bbeafb29a77b70e4162fa09473364 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision f5503aa2bc6bbeafb29a77b70e4162fa09473364) +++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -68,7 +68,7 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new StabilityStoneCoverCalculationsProperties(context.WrappedData) }; @@ -92,7 +92,7 @@ public override IEnumerable GetViewInfos() { - yield return new ViewInfo + yield return new ViewInfo { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, @@ -136,7 +136,7 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( CalculationsChildNodeObjects, CalculationsContextMenuStrip); @@ -285,7 +285,7 @@ #region StabilityStoneCoverCalculationsContext TreeNodeInfo - private static object[] CalculationsChildNodeObjects(StabilityStoneCoverCalculationsContext context) + private static object[] CalculationsChildNodeObjects(StabilityStoneCoverHydraulicLoadsContext context) { StabilityStoneCoverFailureMechanism failureMechanism = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -308,7 +308,7 @@ }; } - private ContextMenuStrip CalculationsContextMenuStrip(StabilityStoneCoverCalculationsContext context, + private ContextMenuStrip CalculationsContextMenuStrip(StabilityStoneCoverHydraulicLoadsContext context, object parentData, TreeViewControl treeViewControl) { @@ -328,12 +328,12 @@ .Build(); } - private static string EnableValidateAndCalculateMenuItemForFailureMechanism(StabilityStoneCoverCalculationsContext context) + private static string EnableValidateAndCalculateMenuItemForFailureMechanism(StabilityStoneCoverHydraulicLoadsContext context) { return EnableValidateAndCalculateMenuItem(context.Parent); } - private void CalculateAllInFailureMechanism(StabilityStoneCoverCalculationsContext context) + private void CalculateAllInFailureMechanism(StabilityStoneCoverHydraulicLoadsContext context) { ActivityProgressDialogRunner.Run( Gui.MainWindow, Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverCalculationsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverHydraulicLoadsContextTest.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverHydraulicLoadsContextTest.cs (revision 0) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverHydraulicLoadsContextTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,54 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.StabilityStoneCover.Data; +using Riskeer.StabilityStoneCover.Forms.PresentationObjects; + +namespace Riskeer.StabilityStoneCover.Forms.Test.PresentationObjects +{ + [TestFixture] + public class StabilityStoneCoverHydraulicLoadsContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + + // Call + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism, context.WrappedData); + Assert.AreSame(assessmentSection, context.Parent); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverCalculationsContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverHydraulicLoadsContextPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverHydraulicLoadsContextPropertyInfoTest.cs (revision 0) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverHydraulicLoadsContextPropertyInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,83 @@ +// 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.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.StabilityStoneCover.Data; +using Riskeer.StabilityStoneCover.Forms.PresentationObjects; +using Riskeer.StabilityStoneCover.Forms.PropertyClasses; + +namespace Riskeer.StabilityStoneCover.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class StabilityStoneCoverHydraulicLoadsContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new StabilityStoneCoverPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(StabilityStoneCoverHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(StabilityStoneCoverCalculationsProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new StabilityStoneCoverPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(StabilityStoneCoverPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(StabilityStoneCoverHydraulicLoadsContext)); + } + } +} \ No newline at end of file Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs =================================================================== diff -u -rfd240e19cd135e570b4589511bf3183834de30b6 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs (.../StabilityStoneCoverPluginTest.cs) (revision fd240e19cd135e570b4589511bf3183834de30b6) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/StabilityStoneCoverPluginTest.cs (.../StabilityStoneCoverPluginTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -54,7 +54,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(StabilityStoneCoverCalculationsContext), + typeof(StabilityStoneCoverHydraulicLoadsContext), typeof(StabilityStoneCoverCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, @@ -85,7 +85,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(StabilityStoneCoverCalculationsContext), + typeof(StabilityStoneCoverHydraulicLoadsContext), typeof(StabilityStoneCoverFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( @@ -118,7 +118,7 @@ // Assert Assert.AreEqual(8, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverCalculationsContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverHydraulicLoadsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StabilityStoneCoverWaveConditionsCalculationContext))); Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverCalculationsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,395 @@ +// 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.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.Main; +using Core.Gui.TestUtil; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +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.StabilityStoneCover.Data; +using Riskeer.StabilityStoneCover.Forms.PresentationObjects; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.StabilityStoneCover.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class StabilityStoneCoverHydraulicLoadsContextTreeNodeInfoTest + { + private const int contextMenuCalculateAllIndex = 2; + + private readonly string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Service, Path.Combine("HydraRingCalculation", "HRD ijsselmeer.sqlite")); + + private MockRepository mocks; + private StabilityStoneCoverPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new StabilityStoneCoverPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StabilityStoneCoverHydraulicLoadsContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_WithContext_ReturnName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual(failureMechanism.Name, nodeText); + } + + [Test] + public void ForeColor_Always_ReturnControlText() + { + // Setup + mocks.ReplayAll(); + + // Call + Color foreColor = info.ForeColor(null); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); + } + + [Test] + public void Image_Always_ReturnFailureMechanismIcon() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, icon); + } + + [Test] + public void ChildNodeObjects_WithContext_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(2, children.Length); + var inputsFolder = (CategoryTreeFolder) children[0]; + Assert.AreEqual("Invoer", inputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); + + Assert.AreEqual(2, inputsFolder.Contents.Count()); + + var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); + Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection); + + var comment = (Comment) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.InputComments, comment); + + var hydraulicBoundariesCalculationGroup = (StabilityStoneCoverWaveConditionsCalculationGroupContext) children[1]; + Assert.AreSame(failureMechanism.WaveConditionsCalculationGroup, hydraulicBoundariesCalculationGroup.WrappedData); + Assert.IsNull(hydraulicBoundariesCalculationGroup.Parent); + Assert.AreSame(failureMechanism, hydraulicBoundariesCalculationGroup.FailureMechanism); + Assert.AreSame(assessmentSection, hydraulicBoundariesCalculationGroup.AssessmentSection); + } + + [Test] + public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).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.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); + } + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] + public void ContextMenuStrip_WithContext_AddCustomItems() + { + // Setup + using (var treeView = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) + { + // Assert + Assert.AreEqual(8, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_CalculateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(new StabilityStoneCoverWaveConditionsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var nodeData = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndex]; + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", calculateItem.ToolTipText); + } + } + } + + [Test] + public void GivenValidCalculations_WhenCalculatingAllFromContextMenu_ThenAllCalculationsScheduled() + { + // Given + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + StabilityStoneCoverWaveConditionsCalculation calculationA = GetValidCalculation(hydraulicBoundaryLocation); + StabilityStoneCoverWaveConditionsCalculation calculationB = GetValidCalculation(hydraulicBoundaryLocation); + List calculations = failureMechanism.WaveConditionsCalculationGroup.Children; + calculations.AddRange(new[] + { + calculationA, + calculationB + }); + + var nodeData = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mainWindow); + + 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(12); + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(); + + // Then + Assert.AreEqual(3, calculationA.Output.BlocksOutput.Count()); + Assert.AreEqual(3, calculationA.Output.ColumnsOutput.Count()); + Assert.AreEqual(3, calculationB.Output.BlocksOutput.Count()); + Assert.AreEqual(3, calculationB.Output.ColumnsOutput.Count()); + } + } + } + + 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 StabilityStoneCoverWaveConditionsCalculation GetValidCalculation(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + return new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + CategoryType = AssessmentSectionCategoryType.LowerLimitNorm, + ForeshoreProfile = new TestForeshoreProfile(true), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + } + }; + } + } +} \ No newline at end of file Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismViewInfoTest.cs =================================================================== diff -u -r2c1b32465515f42a31e3d44821dcd1d879f9cfc6 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismViewInfoTest.cs (.../StabilityStoneCoverFailureMechanismViewInfoTest.cs) (revision 2c1b32465515f42a31e3d44821dcd1d879f9cfc6) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismViewInfoTest.cs (.../StabilityStoneCoverFailureMechanismViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -61,8 +61,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(StabilityStoneCoverCalculationsContext), info.DataType); - Assert.AreEqual(typeof(StabilityStoneCoverCalculationsContext), info.ViewDataType); + Assert.AreEqual(typeof(StabilityStoneCoverHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(StabilityStoneCoverHydraulicLoadsContext), info.ViewDataType); } [Test] @@ -73,7 +73,7 @@ mocks.ReplayAll(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - var context = new StabilityStoneCoverCalculationsContext(failureMechanism, assessmentSection); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -100,7 +100,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new StabilityStoneCoverFailureMechanism(); - var context = new StabilityStoneCoverCalculationsContext(failureMechanism, assessmentSection); + var context = new StabilityStoneCoverHydraulicLoadsContext(failureMechanism, assessmentSection); using (var testForm = new Form()) { Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs =================================================================== diff -u -r1c9e61ac31cc9ac8c9c126cf295bccacdd5c5b8a -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputViewInfoTest.cs) (revision 1c9e61ac31cc9ac8c9c126cf295bccacdd5c5b8a) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -204,7 +204,7 @@ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - return new StabilityStoneCoverCalculationsContext( + return new StabilityStoneCoverHydraulicLoadsContext( new StabilityStoneCoverFailureMechanism { WaveConditionsCalculationGroup = Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverCalculationsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContext.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContext.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContext.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,43 @@ +// 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 Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.Data; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects +{ + /// + /// Presentation object for calculations of . + /// + public class WaveImpactAsphaltCoverHydraulicLoadsContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism. + /// The parent of . + /// Thrown when any parameter is null. + public WaveImpactAsphaltCoverHydraulicLoadsContext(WaveImpactAsphaltCoverFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) + : base(wrappedFailureMechanism, parent) {} + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -raa4f44030799130241257aa7e2e10f7dd7017cc6 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision aa4f44030799130241257aa7e2e10f7dd7017cc6) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -68,7 +68,7 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new WaveImpactAsphaltCoverCalculationsProperties(context.WrappedData) }; @@ -89,7 +89,7 @@ public override IEnumerable GetViewInfos() { - yield return new ViewInfo + yield return new ViewInfo { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, @@ -145,7 +145,7 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( CalculationsChildNodeObjects, CalculationsContextMenuStrip); @@ -285,7 +285,7 @@ #region WaveImpactAsphaltCoverCalculationsContext TreeNodeInfo - private static object[] CalculationsChildNodeObjects(WaveImpactAsphaltCoverCalculationsContext context) + private static object[] CalculationsChildNodeObjects(WaveImpactAsphaltCoverHydraulicLoadsContext context) { WaveImpactAsphaltCoverFailureMechanism failureMechanism = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -308,7 +308,7 @@ }; } - private ContextMenuStrip CalculationsContextMenuStrip(WaveImpactAsphaltCoverCalculationsContext context, + private ContextMenuStrip CalculationsContextMenuStrip(WaveImpactAsphaltCoverHydraulicLoadsContext context, object parentData, TreeViewControl treeViewControl) { @@ -328,12 +328,12 @@ .Build(); } - private static string EnableValidateAndCalculateMenuItemForFailureMechanism(WaveImpactAsphaltCoverCalculationsContext context) + private static string EnableValidateAndCalculateMenuItemForFailureMechanism(WaveImpactAsphaltCoverHydraulicLoadsContext context) { return EnableValidateAndCalculateMenuItem(context.Parent); } - private void CalculateAllInFailureMechanism(WaveImpactAsphaltCoverCalculationsContext context) + private void CalculateAllInFailureMechanism(WaveImpactAsphaltCoverHydraulicLoadsContext context) { ActivityProgressDialogRunner.Run( Gui.MainWindow, Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverCalculationsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContextTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContextTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PresentationObjects/WaveImpactAsphaltCoverHydraulicLoadsContextTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,53 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.Test.PresentationObjects +{ + [TestFixture] + public class WaveImpactAsphaltCoverHydraulicLoadsContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + // Call + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism, context.WrappedData); + Assert.AreSame(assessmentSection, context.Parent); + } + } +} \ No newline at end of file Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverCalculationsContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverHydraulicLoadsContextPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverHydraulicLoadsContextPropertyInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverHydraulicLoadsContextPropertyInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,83 @@ +// 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.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverHydraulicLoadsContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverCalculationsProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveImpactAsphaltCoverHydraulicLoadsContext)); + } + } +} \ No newline at end of file Fisheye: Tag 1dd2c22368f99235c15314f434505d4b5fc27a90 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverCalculationsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest.cs (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -0,0 +1,392 @@ +// 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.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.Main; +using Core.Gui.TestUtil; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +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 RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverHydraulicLoadsContextTreeNodeInfoTest + { + private const int contextMenuCalculateAllIndex = 2; + + private readonly string validFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Service, Path.Combine("HydraRingCalculation", "HRD ijsselmeer.sqlite")); + + private MockRepository mocks; + private WaveImpactAsphaltCoverPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new WaveImpactAsphaltCoverPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverHydraulicLoadsContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + mocks.VerifyAll(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocks.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_WithContext_ReturnName() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + string nodeText = info.Text(context); + + // Assert + Assert.AreEqual(failureMechanism.Name, nodeText); + } + + [Test] + public void ForeColor_Always_ReturnControlText() + { + // Setup + mocks.ReplayAll(); + + // Call + Color foreColor = info.ForeColor(null); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor); + } + + [Test] + public void Image_Always_ReturnFailureMechanismIcon() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + Image icon = info.Image(context); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, icon); + } + + [Test] + public void ChildNodeObjects_WithContext_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(2, children.Length); + var inputsFolder = (CategoryTreeFolder) children[0]; + Assert.AreEqual("Invoer", inputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); + + Assert.AreEqual(2, inputsFolder.Contents.Count()); + var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); + Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); + Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection); + + var comment = (Comment) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.InputComments, comment); + + var hydraulicBoundariesCalculationGroup = (WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext) children[1]; + Assert.AreSame(failureMechanism.WaveConditionsCalculationGroup, hydraulicBoundariesCalculationGroup.WrappedData); + Assert.IsNull(hydraulicBoundariesCalculationGroup.Parent); + Assert.AreSame(failureMechanism, hydraulicBoundariesCalculationGroup.FailureMechanism); + Assert.AreSame(assessmentSection, hydraulicBoundariesCalculationGroup.AssessmentSection); + } + + [Test] + public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var assessmentSection = mocks.Stub(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).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.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); + } + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] + public void ContextMenuStrip_WithContext_AddCustomItems() + { + // Setup + using (var treeView = new TreeViewControl()) + { + var assessmentSection = mocks.Stub(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocks.Stub(); + gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) + { + // Assert + Assert.AreEqual(8, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_CalculateAllDisabled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks); + var nodeData = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndex]; + Assert.IsFalse(calculateItem.Enabled); + Assert.AreEqual("Er is geen hydraulische belastingendatabase geïmporteerd.", calculateItem.ToolTipText); + } + } + } + + [Test] + public void GivenValidCalculations_WhenCalculatingAllFromContextMenu_ThenAllCalculationsScheduled() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput(); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationA = GetValidCalculation(hydraulicBoundaryLocation); + WaveImpactAsphaltCoverWaveConditionsCalculation calculationB = GetValidCalculation(hydraulicBoundaryLocation); + List calculations = failureMechanism.WaveConditionsCalculationGroup.Children; + calculations.AddRange(new[] + { + calculationA, + calculationB + }); + + var nodeData = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks); + + var gui = mocks.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mainWindow); + + 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(6); + mocks.ReplayAll(); + + plugin.Gui = gui; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(); + + // Then + Assert.AreEqual(3, calculationA.Output.Items.Count()); + Assert.AreEqual(3, calculationB.Output.Items.Count()); + } + } + } + + 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, + CategoryType = AssessmentSectionCategoryType.LowerLimitNorm, + ForeshoreProfile = new TestForeshoreProfile(true), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + } + }; + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverFailureMechanismViewInfoTest.cs =================================================================== diff -u -rc9521b6730f18decf3e9232889e00a89dcc9e324 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverFailureMechanismViewInfoTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewInfoTest.cs) (revision c9521b6730f18decf3e9232889e00a89dcc9e324) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverFailureMechanismViewInfoTest.cs (.../WaveImpactAsphaltCoverFailureMechanismViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -61,8 +61,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(WaveImpactAsphaltCoverCalculationsContext), info.DataType); - Assert.AreEqual(typeof(WaveImpactAsphaltCoverCalculationsContext), info.ViewDataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), info.ViewDataType); } [Test] @@ -73,7 +73,7 @@ mocks.ReplayAll(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var context = new WaveImpactAsphaltCoverCalculationsContext(failureMechanism, assessmentSection); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -100,7 +100,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var context = new WaveImpactAsphaltCoverCalculationsContext(failureMechanism, assessmentSection); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); using (var testForm = new Form()) { Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs =================================================================== diff -u -r38960ec42c1c6f6438d7a04ce0f58e114e6ff180 -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs) (revision 38960ec42c1c6f6438d7a04ce0f58e114e6ff180) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -204,7 +204,7 @@ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - return new WaveImpactAsphaltCoverCalculationsContext( + return new WaveImpactAsphaltCoverHydraulicLoadsContext( new WaveImpactAsphaltCoverFailureMechanism { WaveConditionsCalculationGroup = Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs =================================================================== diff -u -r7e8b7562d2dec62c1c5c0a205e1f7f4eca7243fc -r1dd2c22368f99235c15314f434505d4b5fc27a90 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 7e8b7562d2dec62c1c5c0a205e1f7f4eca7243fc) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) @@ -67,7 +67,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(WaveImpactAsphaltCoverCalculationsContext), + typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), typeof(WaveImpactAsphaltCoverCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( @@ -101,7 +101,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(WaveImpactAsphaltCoverCalculationsContext), + typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), typeof(WaveImpactAsphaltCoverFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( @@ -134,7 +134,7 @@ // Assert Assert.AreEqual(8, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverCalculationsContext))); + 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(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext)));