Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContext.cs =================================================================== diff -u --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContext.cs (revision 0) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContext.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -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.HeightStructures.Data; + +namespace Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState +{ + /// + /// Presentation object for in calculations state. + /// + public class HeightStructuresFailureMechanismContext : 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 HeightStructuresFailureMechanismContext(HeightStructuresFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) + : base(wrappedFailureMechanism, parent) {} + } +} \ No newline at end of file Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationsContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/HeightStructuresFailurePathContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContext.cs =================================================================== diff -u --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContext.cs (revision 0) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContext.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -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.HeightStructures.Data; + +namespace Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState +{ + /// + /// Presentation object for in registration state. + /// + public class HeightStructuresFailureMechanismContext : 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 HeightStructuresFailureMechanismContext(HeightStructuresFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) + : base(wrappedFailureMechanism, parent) {} + } +} \ No newline at end of file Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r49dcec749045c1b5350496fd6c26cbc1256938dc -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 49dcec749045c1b5350496fd6c26cbc1256938dc) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -61,6 +61,8 @@ using Riskeer.HeightStructures.IO.Configurations; using Riskeer.HeightStructures.Plugin.FileImporters; using Riskeer.HeightStructures.Service; +using CalculationsStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState.HeightStructuresFailureMechanismContext; +using RegistrationStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState.HeightStructuresFailureMechanismContext; using CalculationsStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState.HeightStructuresFailureMechanismProperties; using RegistrationStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState.HeightStructuresFailureMechanismProperties; using CalculationsStateFailureMechanismView = Riskeer.HeightStructures.Forms.Views.CalculationsState.HeightStructuresFailureMechanismView; @@ -78,11 +80,11 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new CalculationsStateFailureMechanismProperties(context.WrappedData) }; - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData) }; @@ -165,13 +167,13 @@ public override IEnumerable GetViewInfos() { - yield return new RiskeerViewInfo(() => Gui) + yield return new RiskeerViewInfo(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, CreateInstance = context => new CalculationsStateFailureMechanismView(context.WrappedData, context.Parent) }; - yield return new RiskeerViewInfo(() => Gui) + yield return new RiskeerViewInfo(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, AdditionalDataCheck = context => context.WrappedData.InAssembly, @@ -215,11 +217,11 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( CalculationsChildNodeObjects, CalculationsContextMenuStrip); - yield return RiskeerTreeNodeInfoFactory.CreateFailurePathContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailurePathContextTreeNodeInfo( FailurePathEnabledChildNodeObjects, FailurePathDisabledChildNodeObjects, FailurePathEnabledContextMenuStrip, @@ -353,7 +355,7 @@ .FirstOrDefault(); } - if (dataToCloseFor is HeightStructuresCalculationsContext failureMechanismContext) + if (dataToCloseFor is CalculationsStateFailureMechanismContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -367,7 +369,7 @@ #region HeightStructuresCalculationsContext TreeNodeInfo - private static object[] CalculationsChildNodeObjects(HeightStructuresCalculationsContext context) + private static object[] CalculationsChildNodeObjects(CalculationsStateFailureMechanismContext context) { HeightStructuresFailureMechanism wrappedData = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -390,7 +392,7 @@ }; } - private ContextMenuStrip CalculationsContextMenuStrip(HeightStructuresCalculationsContext context, + private ContextMenuStrip CalculationsContextMenuStrip(CalculationsStateFailureMechanismContext context, object parentData, TreeViewControl treeViewControl) { @@ -424,18 +426,18 @@ .Build(); } - private static string EnableValidateAndCalculateMenuItemForFailureMechanism(HeightStructuresCalculationsContext context) + private static string EnableValidateAndCalculateMenuItemForFailureMechanism(CalculationsStateFailureMechanismContext context) { return EnableValidateAndCalculateMenuItem(context.Parent); } - private static void ValidateAllInFailureMechanism(HeightStructuresCalculationsContext context) + private static void ValidateAllInFailureMechanism(CalculationsStateFailureMechanismContext context) { ValidateAll(context.WrappedData.Calculations.OfType>(), context.Parent); } - private void CalculateAllInFailureMechanism(HeightStructuresCalculationsContext context) + private void CalculateAllInFailureMechanism(CalculationsStateFailureMechanismContext context) { ActivityProgressDialogRunner.Run( Gui.MainWindow, @@ -446,7 +448,7 @@ #region HeightStructuresFailurePathContext TreeNodeInfo - private static object[] FailurePathEnabledChildNodeObjects(HeightStructuresFailurePathContext context) + private static object[] FailurePathEnabledChildNodeObjects(RegistrationStateFailureMechanismContext context) { HeightStructuresFailureMechanism failureMechanism = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -460,7 +462,7 @@ }; } - private static object[] FailurePathDisabledChildNodeObjects(HeightStructuresFailurePathContext context) + private static object[] FailurePathDisabledChildNodeObjects(RegistrationStateFailureMechanismContext context) { return new object[] { @@ -488,7 +490,7 @@ }; } - private ContextMenuStrip FailurePathEnabledContextMenuStrip(HeightStructuresFailurePathContext context, + private ContextMenuStrip FailurePathEnabledContextMenuStrip(RegistrationStateFailureMechanismContext context, object parentData, TreeViewControl treeViewControl) { @@ -505,7 +507,7 @@ .Build(); } - private ContextMenuStrip FailurePathDisabledContextMenuStrip(HeightStructuresFailurePathContext context, + private ContextMenuStrip FailurePathDisabledContextMenuStrip(RegistrationStateFailureMechanismContext context, object parentData, TreeViewControl treeViewControl) { @@ -520,7 +522,7 @@ .Build(); } - private void RemoveAllViewsForItem(HeightStructuresFailurePathContext context) + private void RemoveAllViewsForItem(RegistrationStateFailureMechanismContext context) { Gui.ViewCommands.RemoveAllViewsForItem(context); } @@ -857,10 +859,10 @@ { string message = RiskeerCommonFormsResources.VerifyUpdate_Confirm_calculation_output_cleared; if (StructureDependentDataShouldUpdate(new[] - { - calculation - }, message)) { + calculation + }, message)) + { UpdateStructureDerivedCalculationInput(calculation); } } Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContextTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContextTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/CalculationsState/HeightStructuresFailureMechanismContextTest.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -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.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; + +namespace Riskeer.HeightStructures.Forms.Test.PresentationObjects.CalculationsState +{ + [TestFixture] + public class HeightStructuresFailureMechanismContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(assessmentSection, context.Parent); + Assert.AreSame(failureMechanism, context.WrappedData); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationsContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresFailurePathContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContextTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContextTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/RegistrationState/HeightStructuresFailureMechanismContextTest.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -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.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; + +namespace Riskeer.HeightStructures.Forms.Test.PresentationObjects.RegistrationState +{ + [TestFixture] + public class HeightStructuresFailureMechanismContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var context = new HeightStructuresFailureMechanismContext(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/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r49dcec749045c1b5350496fd6c26cbc1256938dc -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 49dcec749045c1b5350496fd6c26cbc1256938dc) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -38,6 +38,8 @@ using Riskeer.HeightStructures.Forms.PresentationObjects; using Riskeer.HeightStructures.Forms.PropertyClasses; using Riskeer.HeightStructures.Forms.Views; +using CalculationsStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState.HeightStructuresFailureMechanismContext; +using RegistrationStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState.HeightStructuresFailureMechanismContext; using CalculationsStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState.HeightStructuresFailureMechanismProperties; using RegistrationStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState.HeightStructuresFailureMechanismProperties; using CalculationsStateFailureMechanismView = Riskeer.HeightStructures.Forms.Views.CalculationsState.HeightStructuresFailureMechanismView; @@ -73,12 +75,12 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(HeightStructuresCalculationsContext), + typeof(CalculationsStateFailureMechanismContext), typeof(CalculationsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(HeightStructuresFailurePathContext), + typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( @@ -109,8 +111,8 @@ // Assert Assert.AreEqual(9, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationsContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresFailurePathContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CalculationsStateFailureMechanismContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RegistrationStateFailureMechanismContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationScenarioContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresInputContext))); @@ -147,12 +149,12 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(HeightStructuresCalculationsContext), + typeof(CalculationsStateFailureMechanismContext), typeof(CalculationsStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(HeightStructuresFailurePathContext), + typeof(RegistrationStateFailureMechanismContext), typeof(RegistrationStateFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs =================================================================== diff -u -r14174f04f6c78b47f5663373e3b6f9e68847646b -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs (.../HeightStructuresFailureMechanismPropertyInfoTest.cs) (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs (.../HeightStructuresFailureMechanismPropertyInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -26,7 +26,7 @@ using Rhino.Mocks; using Riskeer.Common.Data.AssessmentSection; using Riskeer.HeightStructures.Data; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; using Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState; namespace Riskeer.HeightStructures.Plugin.Test.PropertyInfos.CalculationsState @@ -54,7 +54,7 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(HeightStructuresCalculationsContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.DataType); Assert.AreEqual(typeof(HeightStructuresFailureMechanismProperties), info.PropertyObjectType); } @@ -67,7 +67,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresCalculationsContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs =================================================================== diff -u -r14174f04f6c78b47f5663373e3b6f9e68847646b -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs (.../HeightStructuresFailureMechanismPropertyInfoTest.cs) (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs (.../HeightStructuresFailureMechanismPropertyInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -26,7 +26,7 @@ using Rhino.Mocks; using Riskeer.Common.Data.AssessmentSection; using Riskeer.HeightStructures.Data; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; using Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState; namespace Riskeer.HeightStructures.Plugin.Test.PropertyInfos.RegistrationState @@ -54,7 +54,7 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(HeightStructuresFailurePathContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.DataType); Assert.AreEqual(typeof(HeightStructuresFailureMechanismProperties), info.PropertyObjectType); } @@ -67,7 +67,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/CalculationsState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/CalculationsState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/CalculationsState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -0,0 +1,897 @@ +// 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; +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.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.Structures; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Data.TestUtil.IllustrationPoints; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Service.TestUtil; +using Riskeer.HeightStructures.Data; +using Riskeer.HeightStructures.Data.TestUtil; +using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.Data.Input.Structures; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.HeightStructures.Plugin.Test.TreeNodeInfos.CalculationsState +{ + [TestFixture] + public class HeightStructuresFailureMechanismContextTreeNodeInfoTest : NUnitFormTest + { + private const int contextMenuValidateAllIndex = 2; + private const int contextMenuCalculateAllIndex = 3; + private const int contextMenuClearAllIndex = 5; + private const int contextMenuClearIllustrationPointsIndex = 6; + + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, nameof(HydraulicBoundaryDatabase)); + + private MockRepository mocksRepository; + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [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 Text_WithContext_ReturnsName() + { + // Setup + var assessmentSection = mocksRepository.Stub(); + mocksRepository.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual(failureMechanism.Name, text); + } + + [Test] + public void Image_Always_ReturnsFailureMechanismIcon() + { + // Setup + mocksRepository.ReplayAll(); + + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, image); + } + + [Test] + public void ChildNodeObjects_WithContext_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailureMechanismContext(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(3, 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 heightStructuresContext = (HeightStructuresContext) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.HeightStructures, heightStructuresContext.WrappedData); + Assert.AreSame(failureMechanism, heightStructuresContext.FailureMechanism); + Assert.AreSame(assessmentSection, heightStructuresContext.AssessmentSection); + + var calculationsInputComments = (Comment) inputsFolder.Contents.ElementAt(2); + Assert.AreSame(failureMechanism.CalculationsInputComments, calculationsInputComments); + + var calculationsFolder = (HeightStructuresCalculationGroupContext) children[1]; + Assert.AreSame(failureMechanism.CalculationsGroup, calculationsFolder.WrappedData); + Assert.IsNull(calculationsFolder.Parent); + Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism); + } + + [Test] + public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + var assessmentSection = mocksRepository.Stub(); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + var menuBuilder = mocksRepository.StrictMock(); + using (mocksRepository.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.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.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 = mocksRepository.Stub(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) + { + // Assert + Assert.AreEqual(12, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearAllIndex, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIllustrationPointsIndex, + "Wis alle illustratiepunten...", + "Er zijn geen berekeningen met illustratiepunten om te wissen.", + RiskeerCommonFormsResources.ClearIllustrationPointsIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er is geen hydraulische belastingendatabase geïmporteerd.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; + + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.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 faalmechanisme uit.", + RiskeerCommonFormsResources.CalculateAllIcon); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemValidateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndex, + "Alles &valideren", + "Er is geen hydraulische belastingendatabase geïmporteerd.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemValidateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateAllIndex]; + + Assert.AreEqual("Alles &valideren", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ValidateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemValidateAllEnabled() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, + "Alles &valideren", + "Valideer alle berekeningen binnen dit faalmechanisme.", + RiskeerCommonFormsResources.ValidateAllIcon); + } + } + } + + [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new TestHeightStructuresCalculationScenario + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new TestHeightStructuresCalculationScenario + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() + } + }); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "complete.sqlite") + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocksRepository); + + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mainWindow); + + int nrOfCalculators = failureMechanism.Calculations.Count(); + var calculatorFactory = mocksRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator( + Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + HydraulicBoundaryCalculationSettingsFactory.CreateSettings(assessmentSection.HydraulicBoundaryDatabase), + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(new TestStructuresCalculator()) + .Repeat + .Times(nrOfCalculators); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(), messages => + { + List messageList = messages.ToList(); + + // Assert + Assert.AreEqual(14, messageList.Count); + Assert.AreEqual("Uitvoeren van berekening 'A' is gestart.", messageList[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[3]); + StringAssert.StartsWith("Hoogte kunstwerk berekening is uitgevoerd op de tijdelijke locatie", messageList[4]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[5]); + Assert.AreEqual("Uitvoeren van berekening 'A' is gelukt.", messageList[6]); + + Assert.AreEqual("Uitvoeren van berekening 'B' is gestart.", messageList[7]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[8]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[9]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[10]); + StringAssert.StartsWith("Hoogte kunstwerk berekening is uitgevoerd op de tijdelijke locatie", messageList[11]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[12]); + Assert.AreEqual("Uitvoeren van berekening 'B' is gelukt.", messageList[13]); + }); + } + } + } + + [Test] + public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new TestHeightStructuresCalculationScenario + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new TestHeightStructuresCalculationScenario + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + void Call() => contextMenu.Items[contextMenuValidateAllIndex].PerformClick(); + + // Assert + TestHelper.AssertLogMessages(Call, messages => + { + string[] messageList = messages.ToArray(); + + Assert.AreEqual(4, messageList.Length); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[1]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[2]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[3]); + }); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismWithCalculationsContainingIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled() + { + // Setup + var calculationWithIllustrationPoints = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithIllustrationPoints, + calculationWithOutput, + new TestHeightStructuresCalculationScenario() + } + } + }; + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; + + // Assert + Assert.IsTrue(toolStripItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismWithCalculationsWithoutIllustrationPoints_ContextMenuItemClearIllustrationPointsDisabled() + { + // Setup + var calculationWithOutput = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithOutput, + new TestHeightStructuresCalculationScenario() + } + } + }; + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; + + // Assert + Assert.IsFalse(toolStripItem.Enabled); + } + } + } + + [Test] + public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndAborted_ThenInquiryAndIllustrationPointsNotCleared() + { + // Given + var calculationWithIllustrationPoints = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithIllustrationPoints, + calculationWithOutput, + new TestHeightStructuresCalculationScenario() + } + } + }; + + var calculationObserver = mocksRepository.StrictMock(); + calculationWithIllustrationPoints.Attach(calculationObserver); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickCancel(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuClearIllustrationPointsIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u alle illustratiepunten wilt wissen?", messageBoxText); + + Assert.IsTrue(calculationWithOutput.HasOutput); + Assert.IsTrue(calculationWithIllustrationPoints.Output.HasGeneralResult); + } + } + } + + [Test] + public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinued_ThenInquiryAndIllustrationPointsCleared() + { + // Given + var calculationWithIllustrationPoints = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new TestHeightStructuresCalculationScenario + { + Output = new TestStructuresOutput() + }; + + var failureMechanism = new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithIllustrationPoints, + calculationWithOutput, + new TestHeightStructuresCalculationScenario() + } + } + }; + + var affectedCalculationObserver = mocksRepository.StrictMock(); + affectedCalculationObserver.Expect(o => o.UpdateObserver()); + calculationWithIllustrationPoints.Attach(affectedCalculationObserver); + + var unaffectedCalculationObserver = mocksRepository.StrictMock(); + calculationWithOutput.Attach(unaffectedCalculationObserver); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenu.Items[contextMenuClearIllustrationPointsIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u alle illustratiepunten wilt wissen?", messageBoxText); + + Assert.IsTrue(calculationWithOutput.HasOutput); + Assert.IsFalse(calculationWithIllustrationPoints.Output.HasGeneralResult); + } + } + } + + public override void Setup() + { + mocksRepository = new MockRepository(); + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresFailureMechanismContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocksRepository.VerifyAll(); + + base.TearDown(); + } + } +} \ No newline at end of file Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationsContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag de99915e801d15cda0f5bb52eafa3cdfa76479ae refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresFailurePathContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/RegistrationState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/RegistrationState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/RegistrationState/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -0,0 +1,277 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Drawing; +using System.Linq; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.ContextMenu; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Plugin.TestUtil; +using Riskeer.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.HeightStructures.Plugin.Test.TreeNodeInfos.RegistrationState +{ + [TestFixture] + public class HeightStructuresFailureMechanismContextTreeNodeInfoTest + { + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void Setup() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresFailureMechanismContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // 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_ReturnsName() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Hoogte kunstwerk", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsFailureMechanismIcon() + { + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.FailureMechanismIcon, image); + } + + [Test] + public void ChildNodeObjects_FailureMechanismInAssemblyTrue_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailureMechanismContext(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 failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection); + + var inAssemblyInputComments = (Comment) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.InAssemblyInputComments, inAssemblyInputComments); + + var outputsFolder = (CategoryTreeFolder) children[1]; + Assert.AreEqual("Oordeel", outputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); + + Assert.AreEqual(3, outputsFolder.Contents.Count()); + + var scenariosContext = (HeightStructuresScenariosContext) outputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); + + var failureMechanismResultsContext = (HeightStructuresFailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); + Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismResultsContext.AssessmentSection); + + var inAssemblyOutputComments = (Comment) outputsFolder.Contents.ElementAt(2); + Assert.AreSame(failureMechanism.InAssemblyOutputComments, inAssemblyOutputComments); + } + + [Test] + public void ChildNodeObjects_FailureMechanismInAssemblyFalse_ReturnChildDataNodes() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism + { + InAssembly = false + }; + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(1, children.Length); + + var comment = (Comment) children[0]; + Assert.AreSame(failureMechanism.NotInAssemblyComments, comment); + + mocks.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_FailureMechanismInAssemblyTrue_CallsContextMenuBuilderMethods() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailureMechanismContext(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 + mocks.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_FailureMechanismInAssemblyFalse_CallsContextMenuBuilderMethods() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new HeightStructuresFailureMechanism + { + InAssembly = false + }; + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + + var menuBuilder = mocks.StrictMock(); + using (mocks.Ordered()) + { + 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 + mocks.VerifyAll(); + } + + [TestFixture] + public class HeightStructuresFailurePathContextInAssemblyTreeNodeInfoTest : + FailurePathInAssemblyTreeNodeInfoTestFixtureBase + { + public HeightStructuresFailurePathContextInAssemblyTreeNodeInfoTest() : base(2, 0) {} + + protected override HeightStructuresFailureMechanismContext CreateFailureMechanismContext(HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + { + return new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + } + } + } +} \ No newline at end of file Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/CalculationsState/HeightStructuresFailureMechanismViewInfoTest.cs =================================================================== diff -u -r49dcec749045c1b5350496fd6c26cbc1256938dc -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/CalculationsState/HeightStructuresFailureMechanismViewInfoTest.cs (.../HeightStructuresFailureMechanismViewInfoTest.cs) (revision 49dcec749045c1b5350496fd6c26cbc1256938dc) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/CalculationsState/HeightStructuresFailureMechanismViewInfoTest.cs (.../HeightStructuresFailureMechanismViewInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -26,7 +26,7 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.TestUtil; using Riskeer.HeightStructures.Data; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; using Riskeer.HeightStructures.Forms.Views.CalculationsState; namespace Riskeer.HeightStructures.Plugin.Test.ViewInfos.CalculationsState @@ -56,8 +56,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(HeightStructuresCalculationsContext), info.DataType); - Assert.AreEqual(typeof(HeightStructuresCalculationsContext), info.ViewDataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.ViewDataType); } [Test] @@ -68,7 +68,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresCalculationsContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -84,7 +84,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresCalculationsContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call var view = (HeightStructuresFailureMechanismView) info.CreateInstance(context); Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresCalculationsViewInfoTest.cs =================================================================== diff -u -rc5219e29c90757003a649a2b39d0e18fcbad1782 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresCalculationsViewInfoTest.cs (.../HeightStructuresCalculationsViewInfoTest.cs) (revision c5219e29c90757003a649a2b39d0e18fcbad1782) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresCalculationsViewInfoTest.cs (.../HeightStructuresCalculationsViewInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -30,6 +30,7 @@ using Riskeer.Common.Data.TestUtil; using Riskeer.HeightStructures.Data; using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; using Riskeer.HeightStructures.Forms.Views; namespace Riskeer.HeightStructures.Plugin.Test.ViewInfos @@ -197,7 +198,7 @@ using (var view = new HeightStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { - var context = new HeightStructuresCalculationsContext(new HeightStructuresFailureMechanism(), assessmentSection); + var context = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), assessmentSection); // Call bool closeForData = info.CloseForData(view, context); @@ -216,7 +217,7 @@ using (var view = new HeightStructuresCalculationsView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { - var context = new HeightStructuresCalculationsContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool closeForData = info.CloseForData(view, context); Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -rc5219e29c90757003a649a2b39d0e18fcbad1782 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision c5219e29c90757003a649a2b39d0e18fcbad1782) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -31,6 +31,7 @@ using Riskeer.Common.Forms.Views; using Riskeer.HeightStructures.Data; using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; namespace Riskeer.HeightStructures.Plugin.Test.ViewInfos { @@ -215,7 +216,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); var view = new StructuresFailureMechanismResultView( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => double.NaN); @@ -237,7 +238,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(new HeightStructuresFailureMechanism(), assessmentSection); + var context = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), assessmentSection); var view = new StructuresFailureMechanismResultView( failureMechanism.SectionResults, failureMechanism, assessmentSection, (fm, ass) => double.NaN); Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs =================================================================== diff -u -rc5219e29c90757003a649a2b39d0e18fcbad1782 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs (.../HeightStructuresScenariosViewInfoTest.cs) (revision c5219e29c90757003a649a2b39d0e18fcbad1782) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs (.../HeightStructuresScenariosViewInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -29,6 +29,7 @@ using Riskeer.Common.Data.FailureMechanism; using Riskeer.HeightStructures.Data; using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; using Riskeer.HeightStructures.Forms.Views; namespace Riskeer.HeightStructures.Plugin.Test.ViewInfos @@ -202,7 +203,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(new HeightStructuresFailureMechanism(), assessmentSection); + var context = new HeightStructuresFailureMechanismContext(new HeightStructuresFailureMechanism(), assessmentSection); using (var view = new HeightStructuresScenariosView(failureMechanism.CalculationsGroup, failureMechanism)) { @@ -225,7 +226,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var view = new HeightStructuresScenariosView(failureMechanism.CalculationsGroup, failureMechanism)) { Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/RegistrationState/HeightStructuresFailurePathViewInfoTest.cs =================================================================== diff -u -r49dcec749045c1b5350496fd6c26cbc1256938dc -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/RegistrationState/HeightStructuresFailurePathViewInfoTest.cs (.../HeightStructuresFailurePathViewInfoTest.cs) (revision 49dcec749045c1b5350496fd6c26cbc1256938dc) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/RegistrationState/HeightStructuresFailurePathViewInfoTest.cs (.../HeightStructuresFailurePathViewInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -26,7 +26,7 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.TestUtil; using Riskeer.HeightStructures.Data; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; using Riskeer.HeightStructures.Forms.Views.RegistrationState; namespace Riskeer.HeightStructures.Plugin.Test.ViewInfos.RegistrationState @@ -56,8 +56,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(HeightStructuresFailurePathContext), info.DataType); - Assert.AreEqual(typeof(HeightStructuresFailurePathContext), info.ViewDataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismContext), info.ViewDataType); } [Test] @@ -68,7 +68,7 @@ mocks.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call string viewName = info.GetViewName(null, context); @@ -91,7 +91,7 @@ InAssembly = inAssembly }; - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call bool result = info.AdditionalDataCheck(context); @@ -108,7 +108,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new HeightStructuresFailurePathContext(failureMechanism, assessmentSection); + var context = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); // Call var view = (HeightStructuresFailureMechanismView) info.CreateInstance(context); Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r0a681eea5c0949690e9a61d735f2f02e8523dc99 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 0a681eea5c0949690e9a61d735f2f02e8523dc99) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -71,7 +71,6 @@ using Riskeer.Common.Util.Helpers; using Riskeer.Common.Util.TypeConverters; using Riskeer.DuneErosion.Plugin.Handlers; -using Riskeer.HeightStructures.Forms.PresentationObjects; using Riskeer.Integration.Data; using Riskeer.Integration.Data.StandAlone; using Riskeer.Integration.Data.StandAlone.AssemblyFactories; @@ -105,6 +104,8 @@ using GrassCoverErosionInwardsRegistrationStateFailureMechanismContext = Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects.RegistrationState.GrassCoverErosionInwardsFailureMechanismContext; using GrassCoverErosionOutwardsHydraulicLoadsStateFailureMechanismContext = Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects.HydraulicLoadsState.GrassCoverErosionOutwardsFailureMechanismContext; using GrassCoverErosionOutwardsRegistrationStateFailureMechanismContext = Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects.RegistrationState.GrassCoverErosionOutwardsFailureMechanismContext; +using HeightStructuresCalculationsStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState.HeightStructuresFailureMechanismContext; +using HeightStructuresRegistrationStateFailureMechanismContext = Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState.HeightStructuresFailureMechanismContext; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; using RiskeerCommonUtilResources = Riskeer.Common.Util.Properties.Resources; @@ -1780,7 +1781,7 @@ new PipingCalculationsContext(assessmentSection.Piping, assessmentSection), new GrassCoverErosionInwardsCalculationsStateFailureMechanismContext(assessmentSection.GrassCoverErosionInwards, assessmentSection), new MacroStabilityInwardsCalculationsContext(assessmentSection.MacroStabilityInwards, assessmentSection), - new HeightStructuresCalculationsContext(assessmentSection.HeightStructures, assessmentSection), + new HeightStructuresCalculationsStateFailureMechanismContext(assessmentSection.HeightStructures, assessmentSection), new ClosingStructuresCalculationsStateFailureMechanismContext(assessmentSection.ClosingStructures, assessmentSection), new StabilityPointStructuresCalculationsContext(assessmentSection.StabilityPointStructures, assessmentSection) }; @@ -1864,7 +1865,7 @@ new GrassCoverErosionOutwardsRegistrationStateFailureMechanismContext(assessmentSection.GrassCoverErosionOutwards, assessmentSection), new GrassCoverSlipOffOutwardsFailurePathContext(assessmentSection.GrassCoverSlipOffOutwards, assessmentSection), new GrassCoverSlipOffInwardsFailurePathContext(assessmentSection.GrassCoverSlipOffInwards, assessmentSection), - new HeightStructuresFailurePathContext(assessmentSection.HeightStructures, assessmentSection), + new HeightStructuresRegistrationStateFailureMechanismContext(assessmentSection.HeightStructures, assessmentSection), new ClosingStructuresRegistrationStateFailureMechanismContext(assessmentSection.ClosingStructures, assessmentSection), new PipingStructureFailurePathContext(assessmentSection.PipingStructure, assessmentSection), new StabilityPointStructuresFailurePathContext(assessmentSection.StabilityPointStructures, assessmentSection), Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs =================================================================== diff -u -rfed9733b56393f58871b000d6c8439dd2fd06178 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs (.../CalculationsStateRootContextTreeNodeInfoTest.cs) (revision fed9733b56393f58871b000d6c8439dd2fd06178) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs (.../CalculationsStateRootContextTreeNodeInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -34,7 +34,7 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Plugin.TestUtil; using Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects.CalculationsState; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.CalculationsState; using Riskeer.Integration.Data; using Riskeer.Integration.Forms.PresentationObjects; using Riskeer.MacroStabilityInwards.Forms.PresentationObjects; @@ -179,9 +179,9 @@ Assert.AreSame(assessmentSection.MacroStabilityInwards, macroStabilityInwardsCalculationsContext.WrappedData); Assert.AreSame(assessmentSection, macroStabilityInwardsCalculationsContext.Parent); - var heightStructuresCalculationsContext = (HeightStructuresCalculationsContext) objects[3]; - Assert.AreSame(assessmentSection.HeightStructures, heightStructuresCalculationsContext.WrappedData); - Assert.AreSame(assessmentSection, heightStructuresCalculationsContext.Parent); + var heightStructuresFailureMechanismContext = (HeightStructuresFailureMechanismContext) objects[3]; + Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent); var closingStructuresFailureMechanismContext = (ClosingStructuresFailureMechanismContext) objects[4]; Assert.AreSame(assessmentSection.ClosingStructures, closingStructuresFailureMechanismContext.WrappedData); Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/GenericFailureMechanismsContextTreeNodeInfoTest.cs =================================================================== diff -u -r0a681eea5c0949690e9a61d735f2f02e8523dc99 -rde99915e801d15cda0f5bb52eafa3cdfa76479ae --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/GenericFailureMechanismsContextTreeNodeInfoTest.cs (.../GenericFailureMechanismsContextTreeNodeInfoTest.cs) (revision 0a681eea5c0949690e9a61d735f2f02e8523dc99) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/GenericFailureMechanismsContextTreeNodeInfoTest.cs (.../GenericFailureMechanismsContextTreeNodeInfoTest.cs) (revision de99915e801d15cda0f5bb52eafa3cdfa76479ae) @@ -33,7 +33,7 @@ using Riskeer.DuneErosion.Forms.PresentationObjects.RegistrationState; using Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects.RegistrationState; using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects.RegistrationState; -using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PresentationObjects.RegistrationState; using Riskeer.Integration.Data; using Riskeer.Integration.Forms.PresentationObjects; using Riskeer.Integration.Forms.PresentationObjects.StandAlone; @@ -216,9 +216,9 @@ Assert.AreSame(assessmentSection.GrassCoverSlipOffInwards, grassCoverSlipOffInwardsFailurePathContext.WrappedData); Assert.AreSame(assessmentSection, grassCoverSlipOffInwardsFailurePathContext.Parent); - var heightStructuresFailurePathContext = (HeightStructuresFailurePathContext) objects[10]; - Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailurePathContext.WrappedData); - Assert.AreSame(assessmentSection, heightStructuresFailurePathContext.Parent); + var heightStructuresFailureMechanismContext = (HeightStructuresFailureMechanismContext) objects[10]; + Assert.AreSame(assessmentSection.HeightStructures, heightStructuresFailureMechanismContext.WrappedData); + Assert.AreSame(assessmentSection, heightStructuresFailureMechanismContext.Parent); var closingStructuresFailureMechanismContext = (ClosingStructuresFailureMechanismContext) objects[11]; Assert.AreSame(assessmentSection.ClosingStructures, closingStructuresFailureMechanismContext.WrappedData);