Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -raea2b44bdcfe43c80d20b790e8b4994f841040f1 -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision aea2b44bdcfe43c80d20b790e8b4994f841040f1) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -90,11 +90,11 @@ - + UserControl - - PipingCalculationInputView.cs + + PipingInputView.cs @@ -213,8 +213,8 @@ Resources.Designer.cs Designer - - PipingCalculationInputView.cs + + PipingInputView.cs PipingCalculationsView.cs Fisheye: Tag 985b7690055ffc0570e0608c3de6c2f645cafc3b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationInputView.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 985b7690055ffc0570e0608c3de6c2f645cafc3b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationInputView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 985b7690055ffc0570e0608c3de6c2f645cafc3b refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationInputView.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -0,0 +1,58 @@ +namespace Ringtoets.Piping.Forms.Views +{ + partial class PipingInputView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.chartControl = new Core.Components.OxyPlot.Forms.ChartControl(); + this.SuspendLayout(); + // + // chartControl + // + this.chartControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.chartControl.Location = new System.Drawing.Point(0, 0); + this.chartControl.MinimumSize = new System.Drawing.Size(50, 75); + this.chartControl.Name = "chartControl"; + this.chartControl.Size = new System.Drawing.Size(150, 150); + this.chartControl.TabIndex = 0; + this.chartControl.Text = "chartControl1"; + // + // PipingInputView + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.chartControl); + this.Name = "PipingInputView"; + this.ResumeLayout(false); + + } + + #endregion + + private Core.Components.OxyPlot.Forms.ChartControl chartControl; + } +} Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -0,0 +1,50 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Forms; +using Core.Components.Charting.Forms; + +namespace Ringtoets.Piping.Forms.Views +{ + /// + /// This class is a view to show the piping input. + /// + public partial class PipingInputView : UserControl, IChartView + { + /// + /// Creates a new instance of . + /// + public PipingInputView() + { + InitializeComponent(); + } + + public object Data { get; set; } + + public IChartControl Chart + { + get + { + return chartControl; + } + } + } +} Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.resx =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.resx (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.resx (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -r4810ae37235b576747c1ef5c37573aa143aab5e5 -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 4810ae37235b576747c1ef5c37573aa143aab5e5) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -110,6 +110,14 @@ view.PipingFailureMechanism = context.FailureMechanism; } }; + + yield return new ViewInfo + { + GetViewData = context => context.WrappedData, + GetViewName = (view, input) => PipingFormsResources.PipingInputContext_NodeDisplayName, + Image = PipingFormsResources.PipingInputIcon, + CloseForData = ClosePipingInutViewForData + }; } public override IEnumerable GetTreeNodeInfos() @@ -301,6 +309,54 @@ #endregion endregion + #region PipingInputView ViewInfo + + private bool ClosePipingInutViewForData(PipingInputView view, object o) + { + var pipingCalculationScenarioContext = o as PipingCalculationScenarioContext; + if (pipingCalculationScenarioContext != null) + { + return ReferenceEquals(view.Data, pipingCalculationScenarioContext.WrappedData.InputParameters); + } + + IEnumerable calculationInputs = null; + + var pipingCalculationGroupContext = o as PipingCalculationGroupContext; + if (pipingCalculationGroupContext != null) + { + calculationInputs = pipingCalculationGroupContext.WrappedData.GetCalculations() + .OfType() + .Select(c => c.InputParameters); + } + + var pipingFailureMechanismContext = o as PipingFailureMechanismContext; + if (pipingFailureMechanismContext != null) + { + calculationInputs = pipingFailureMechanismContext.WrappedData.CalculationsGroup.GetCalculations() + .OfType() + .Select(c => c.InputParameters); + } + + var assessmentSection = o as IAssessmentSection; + if (assessmentSection != null) + { + var failureMechanism = assessmentSection.GetFailureMechanisms() + .OfType() + .FirstOrDefault(); + + if (failureMechanism != null) + { + calculationInputs = failureMechanism.CalculationsGroup.GetCalculations() + .OfType() + .Select(c => c.InputParameters); + } + } + + return calculationInputs != null && calculationInputs.Any(ci => ReferenceEquals(view.Data, ci)); + } + + #endregion + # region Piping TreeNodeInfo private ContextMenuStrip FailureMechanismEnabledContextMenuStrip(PipingFailureMechanismContext pipingFailureMechanismContext, object parentData, TreeViewControl treeViewControl) Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj =================================================================== diff -u -r60f9f8cfadfe1b22e5989aa92ab9839c4623338d -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 60f9f8cfadfe1b22e5989aa92ab9839c4623338d) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -107,6 +107,11 @@ Core.Common.Version False + + {2465cca1-c505-4827-9454-4fd5fd9194cd} + Core.Components.Charting.Forms + False + {4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5} Core.Components.Gis.Forms Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -raea2b44bdcfe43c80d20b790e8b4994f841040f1 -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision aea2b44bdcfe43c80d20b790e8b4994f841040f1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -98,7 +98,7 @@ - + Fisheye: Tag 985b7690055ffc0570e0608c3de6c2f645cafc3b refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationInputViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -0,0 +1,45 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Windows.Forms; +using Core.Components.Charting.Forms; +using NUnit.Framework; +using Ringtoets.Piping.Forms.Views; + +namespace Ringtoets.Piping.Forms.Test.Views +{ + [TestFixture] + public class PipingInputViewTest + { + [Test] + public void DefaultConstructor_DefaultValues() + { + // Call + var view = new PipingInputView(); + + // Assert + Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); + Assert.IsNotNull(view.Chart); + Assert.IsNull(view.Data); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs =================================================================== diff -u -r14de3deecd2cff7f6abe41ed6dc5dc016c4c81e0 -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs (.../PipingGuiPluginTest.cs) (revision 14de3deecd2cff7f6abe41ed6dc5dc016c4c81e0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingGuiPluginTest.cs (.../PipingGuiPluginTest.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -173,11 +173,12 @@ ViewInfo[] viewInfos = guiPlugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(3, viewInfos.Length); + Assert.AreEqual(4, viewInfos.Length); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingFailureMechanismView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingCalculationsView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingFailureMechanismResultView))); + Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingInputView))); } } } Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -raea2b44bdcfe43c80d20b790e8b4994f841040f1 -r985b7690055ffc0570e0608c3de6c2f645cafc3b --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision aea2b44bdcfe43c80d20b790e8b4994f841040f1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -67,6 +67,7 @@ + @@ -96,6 +97,10 @@ {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil + + {2465CCA1-C505-4827-9454-4FD5FD9194CD} + Core.Components.Charting.Forms + {4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5} Core.Components.Gis.Forms Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) @@ -0,0 +1,516 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.Views; +using Ringtoets.Piping.Primitives; +using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; + +namespace Ringtoets.Piping.Plugin.Test.ViewInfos +{ + [TestFixture] + public class PipingInputViewInfoTest + { + private MockRepository mocks; + private PipingGuiPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new PipingGuiPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(PipingInputView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(PipingInputContext), info.DataType); + Assert.AreEqual(typeof(PipingInput), info.ViewDataType); + TestHelper.AssertImagesAreEqual(PipingFormsResources.PipingInputIcon, info.Image); + } + + [Test] + public void GetViewName_Always_ReturnsCalculationName() + { + // Setup + PipingInputView view = new PipingInputView(); + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()); + + // Call + string viewName = info.GetViewName(view, pipingInput); + + // Assert + Assert.AreEqual(PipingFormsResources.PipingInputContext_NodeDisplayName, viewName); + } + + [Test] + public void GetViewData_Always_ReturnsWrappedCalculation() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()); + + string name = "Calculation name"; + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()) + { + Name = name + }; + PipingInputContext calculationInputContext = new PipingInputContext(pipingInput, calculation, Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + // Call + object viewData = info.GetViewData(calculationInputContext); + + // Assert + Assert.AreEqual(pipingInput, viewData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedPipingCalculationScenarioContext_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario pipingCalculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingCalculationScenarioContext pipingCalculationScenarioContext = new PipingCalculationScenarioContext(pipingCalculation, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = pipingCalculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, pipingCalculationScenarioContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedPipingCalculationScenarioContext_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario pipingCalculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingCalculationScenario calculationToRemove = new PipingCalculationScenario(new GeneralPipingInput()); + + PipingCalculationScenarioContext pipingCalculationScenarioContext = new PipingCalculationScenarioContext(calculationToRemove, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = pipingCalculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, pipingCalculationScenarioContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingWithRemovedPipingCalculationGroupContext_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingCalculationGroupContext calculationGroupContext = new PipingCalculationGroupContext(calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, calculationGroupContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingWithRemovedPipingCalculationGroupContext_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingCalculationGroupContext calculationGroupContext = new PipingCalculationGroupContext(new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, calculationGroupContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewCorrespondingWithRemovedParentPipingCalculationGroupContext_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + CalculationGroup nestedGroup = new CalculationGroup(); + nestedGroup.Children.Add(calculation); + calculationGroup.Children.Add(nestedGroup); + + PipingCalculationGroupContext calculationGroupContext = new PipingCalculationGroupContext(calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, calculationGroupContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewNotCorrespondingWithRemovedParentPipingCalculationGroupContext_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + CalculationGroup nestedGroup = new CalculationGroup(); + nestedGroup.Children.Add(calculation); + calculationGroup.Children.Add(nestedGroup); + + PipingCalculationGroupContext calculationGroupContext = new PipingCalculationGroupContext(new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, calculationGroupContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + PipingFailureMechanismContext failureMechanismContext = new PipingFailureMechanismContext(failureMechanism, assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + PipingFailureMechanismContext failureMechanismContext = new PipingFailureMechanismContext(new PipingFailureMechanism(), assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationGroup); + + PipingFailureMechanismContext failureMechanismContext = new PipingFailureMechanismContext(failureMechanism, assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationGroup); + + PipingFailureMechanismContext failureMechanismContext = new PipingFailureMechanismContext(new PipingFailureMechanism(), assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, failureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + IAssessmentSection assessmentSection = mocks.StrictMock(); + assessmentSection.Expect(section => section.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + + mocks.ReplayAll(); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculation); + + IAssessmentSection assessmentSection = mocks.StrictMock(); + assessmentSection.Expect(section => section.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + + mocks.ReplayAll(); + + PipingInputView view = new PipingInputView + { + Data = new PipingCalculationScenario(new GeneralPipingInput()).InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationGroup); + + IAssessmentSection assessmentSection = mocks.StrictMock(); + assessmentSection.Expect(section => section.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + + mocks.ReplayAll(); + + PipingInputView view = new PipingInputView + { + Data = calculation.InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_NestedViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + CalculationGroup calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(calculation); + + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(calculationGroup); + + IAssessmentSection assessmentSection = mocks.StrictMock(); + assessmentSection.Expect(section => section.GetFailureMechanisms()).Return(new[] + { + failureMechanism + }); + + mocks.ReplayAll(); + + PipingInputView view = new PipingInputView + { + Data = new PipingCalculationScenario(new GeneralPipingInput()).InputParameters + }; + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } +} \ No newline at end of file