Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r088018565559b91dddc21fbc06ab8b2bc582ce76 -r3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 088018565559b91dddc21fbc06ab8b2bc582ce76) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -1818,7 +1818,7 @@ { return new object[] { - new PipingFailureMechanismFailurePathStateContext(assessmentSection.Piping, assessmentSection) + new PipingFailurePathContext(assessmentSection.Piping, assessmentSection) }; } Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/FailurePathsStateRootContextTreeNodeInfoTest.cs =================================================================== diff -u -r8dc401612416d696f64ffa9d972c47599bcbba9e -r3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/FailurePathsStateRootContextTreeNodeInfoTest.cs (.../FailurePathsStateRootContextTreeNodeInfoTest.cs) (revision 8dc401612416d696f64ffa9d972c47599bcbba9e) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/FailurePathsStateRootContextTreeNodeInfoTest.cs (.../FailurePathsStateRootContextTreeNodeInfoTest.cs) (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -162,9 +162,9 @@ Assert.AreEqual(TreeFolderCategory.General, failurePathsFolder.Category); Assert.AreEqual(1, failurePathsFolder.Contents.Count()); - var pipingFailurePathsContext = (PipingFailureMechanismFailurePathStateContext) failurePathsFolder.Contents.ElementAt(0); - Assert.AreSame(assessmentSection.Piping, pipingFailurePathsContext.WrappedData); - Assert.AreSame(assessmentSection, pipingFailurePathsContext.Parent); + var pipingFailurePathContext = (PipingFailurePathContext) failurePathsFolder.Contents.ElementAt(0); + Assert.AreSame(assessmentSection.Piping, pipingFailurePathContext.WrappedData); + Assert.AreSame(assessmentSection, pipingFailurePathContext.Parent); var assemblyResultsContext = (AssemblyResultsContext) objects[1]; Assert.AreSame(assessmentSection, assemblyResultsContext.WrappedData); Fisheye: Tag 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 refers to a dead (removed) revision in file `Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/PipingFailureMechanismFailurePathStateContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/PipingFailurePathContext.cs =================================================================== diff -u --- Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/PipingFailurePathContext.cs (revision 0) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/PresentationObjects/PipingFailurePathContext.cs (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -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.Piping.Data; + +namespace Riskeer.Piping.Forms.PresentationObjects +{ + /// + /// Presentation object for the failure path of . + /// + public class PipingFailurePathContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The failure mechanism. + /// The parent of . + /// Thrown when any parameter is null. + public PipingFailurePathContext(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r03a867d546a9c581727a40554141f9db44571888 -r3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 --- Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 03a867d546a9c581727a40554141f9db44571888) +++ Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -374,9 +374,9 @@ FailureMechanismCalculationStateChildNodeObjects, FailureMechanismCalculationStateContextMenuStrip); - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( - FailureMechanismFailurePathStateChildNodeObjects, - FailureMechanismFailurePathStateContextMenuStrip); + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismStateContextTreeNodeInfo( + FailurePathChildNodeObjects, + FailurePathContextMenuStrip); yield return RiskeerTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo( SemiProbabilisticPipingCalculationScenarioContextChildNodeObjects, @@ -868,21 +868,21 @@ #endregion - #region PipingFailureMechanismFailurePathStateContext TreeNodeInfo + #region PipingFailurePathContext TreeNodeInfo - private static object[] FailureMechanismFailurePathStateChildNodeObjects(PipingFailureMechanismFailurePathStateContext context) + private static object[] FailurePathChildNodeObjects(PipingFailurePathContext context) { PipingFailureMechanism wrappedData = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; return new object[] { - new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetFailurePathStateInput(wrappedData, assessmentSection), TreeFolderCategory.Input), - new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData, assessmentSection), TreeFolderCategory.Output) + new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetFailurePathInputs(wrappedData, assessmentSection), TreeFolderCategory.Input), + new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetFailurePathOutputs(wrappedData, assessmentSection), TreeFolderCategory.Output) }; } - private static IEnumerable GetFailurePathStateInput(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + private static IEnumerable GetFailurePathInputs(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { return new object[] { @@ -891,7 +891,7 @@ }; } - private static IEnumerable GetOutputs(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + private static IEnumerable GetFailurePathOutputs(PipingFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { PipingProbabilityAssessmentInput probabilityAssessmentInput = failureMechanism.PipingProbabilityAssessmentInput; return new object[] @@ -905,9 +905,9 @@ }; } - private ContextMenuStrip FailureMechanismFailurePathStateContextMenuStrip(PipingFailureMechanismFailurePathStateContext context, - object parentData, - TreeViewControl treeViewControl) + private ContextMenuStrip FailurePathContextMenuStrip(PipingFailurePathContext context, + object parentData, + TreeViewControl treeViewControl) { var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl)); Fisheye: Tag 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 refers to a dead (removed) revision in file `Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/PipingFailureMechanismFailurePathStateContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/PipingFailurePathContextTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/PipingFailurePathContextTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PresentationObjects/PipingFailurePathContextTest.cs (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -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.Piping.Data; +using Riskeer.Piping.Forms.PresentationObjects; + +namespace Riskeer.Piping.Forms.Test.PresentationObjects +{ + [TestFixture] + public class PipingFailurePathContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + // Call + var context = new PipingFailurePathContext(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/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -r03a867d546a9c581727a40554141f9db44571888 -r3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 03a867d546a9c581727a40554141f9db44571888) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -151,7 +151,7 @@ // Assert Assert.AreEqual(20, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingFailureMechanismCalculationStateContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingFailureMechanismFailurePathStateContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLinesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingSurfaceLine))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PipingStochasticSoilModelCollectionContext))); Fisheye: Tag 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3 refers to a dead (removed) revision in file `Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/TreeNodeInfos/PipingFailureMechanismFailurePathStateContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/TreeNodeInfos/PipingFailurePathContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/TreeNodeInfos/PipingFailurePathContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/TreeNodeInfos/PipingFailurePathContextTreeNodeInfoTest.cs (revision 3a12a88a3bd19ce54dee64c3ee747df3f8475ce3) @@ -0,0 +1,215 @@ +// 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 Core.Gui.Forms.MainWindow; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Probability; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Piping.Data; +using Riskeer.Piping.Forms.PresentationObjects; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using CoreGuiResources = Core.Gui.Properties.Resources; + +namespace Riskeer.Piping.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class PipingFailurePathContextTreeNodeInfoTest : NUnitFormTest + { + private PipingPlugin plugin; + private TreeNodeInfo info; + + [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_Always_ReturnsName() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new PipingFailurePathContext(new PipingFailureMechanism(), assessmentSection); + + // Call + string text = info.Text(context); + + // Assert + Assert.AreEqual("Dijken en dammen - Piping", text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnsPipingIcon() + { + // Call + Image image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.HydraulicCalculationIcon, image); + } + + [Test] + public void ChildNodeObjects_Always_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new PipingFailureMechanism(); + var context = new PipingFailurePathContext(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 comment = (Comment) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.InputComments, comment); + + var outputsFolder = (CategoryTreeFolder) children[1]; + Assert.AreEqual("Oordeel", outputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); + + Assert.AreEqual(4, outputsFolder.Contents.Count()); + var failureMechanismAssemblyCategoriesContext = (FailureMechanismAssemblyCategoriesContext) outputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism, failureMechanismAssemblyCategoriesContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismAssemblyCategoriesContext.AssessmentSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator; + + failureMechanismAssemblyCategoriesContext.GetFailureMechanismSectionAssemblyCategoriesFunc(); + PipingProbabilityAssessmentInput probabilityAssessmentInput = failureMechanism.PipingProbabilityAssessmentInput; + Assert.AreEqual(probabilityAssessmentInput.GetN(assessmentSection.ReferenceLine.Length), calculator.AssemblyCategoriesInput.N); + } + + var failureMechanismScenariosContext = (PipingScenariosContext) outputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism, failureMechanismScenariosContext.FailureMechanism); + Assert.AreSame(failureMechanism.CalculationsGroup, failureMechanismScenariosContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismScenariosContext.AssessmentSection); + + var failureMechanismResultsContext = (ProbabilityFailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(2); + Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); + Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismResultsContext.AssessmentSection); + + var commentContext = (Comment) outputsFolder.Contents.ElementAt(3); + Assert.AreSame(failureMechanism.OutputComments, commentContext); + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + + using (var treeViewControl = new TreeViewControl()) + { + var failureMechanism = new PipingFailureMechanism(); + var context = new PipingFailurePathContext(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.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); + gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + mocks.VerifyAll(); + } + + public override void Setup() + { + plugin = new PipingPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(PipingFailurePathContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + + base.TearDown(); + } + } +} \ No newline at end of file