Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs =================================================================== diff -u -rb784ac8be54e88a798f4b7b7ad54ffe47b587e20 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs (.../HeightStructuresCalculation.cs) (revision b784ac8be54e88a798f4b7b7ad54ffe47b587e20) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs (.../HeightStructuresCalculation.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base; using Ringtoets.Common.Data.Calculation; using Ringtoets.HeightStructures.Data.Properties; @@ -33,9 +34,11 @@ /// /// Creates a new instance of . /// - public HeightStructuresCalculation() + /// General grass cover erosion inwards calculation input parameters that apply to each calculation. + /// When is null. + public HeightStructuresCalculation(GeneralHeightStructuresInput generalInputParameters) { - InputParameters = new HeightStructuresInput(new GeneralHeightStructuresInput()); + InputParameters = new HeightStructuresInput(generalInputParameters); Name = Resources.HeightStructuresCalculation_DefaultName; } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs =================================================================== diff -u -re24eab2c6007074685556ec97dbe45940a520687 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision e24eab2c6007074685556ec97dbe45940a520687) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresFailureMechanism.cs (.../HeightStructuresFailureMechanism.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -45,6 +45,7 @@ sectionResults = new List(); CalculationsGroup = new CalculationGroup(RingtoetsCommonDataResources.FailureMechanism_Calculations_DisplayName, false); NormProbabilityInput = new NormProbabilityInput(); + GeneralInput = new GeneralHeightStructuresInput(); } public override IEnumerable Calculations @@ -60,6 +61,11 @@ /// public NormProbabilityInput NormProbabilityInput { get; private set; } + /// + /// Gets the height structures calculation input parameters that apply to each calculation. + /// + public GeneralHeightStructuresInput GeneralInput { get; private set; } + public CalculationGroup CalculationsGroup { get; private set; } public IEnumerable SectionResults Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs =================================================================== diff -u -re24eab2c6007074685556ec97dbe45940a520687 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision e24eab2c6007074685556ec97dbe45940a520687) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -264,7 +264,7 @@ private static void AddCalculation(HeightStructuresCalculationGroupContext context) { - var calculation = new HeightStructuresCalculation + var calculation = new HeightStructuresCalculation(context.FailureMechanism.GeneralInput) { Name = NamingHelper.GetUniqueName(context.WrappedData.Children, HeightStructuresDataResources.HeightStructuresCalculation_DefaultName, c => c.Name) }; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresCalculationTest.cs =================================================================== diff -u -r47d80506f9f8166de93579dbba94e57f4101927b -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresCalculationTest.cs (.../HeightStructuresCalculationTest.cs) (revision 47d80506f9f8166de93579dbba94e57f4101927b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresCalculationTest.cs (.../HeightStructuresCalculationTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; @@ -29,10 +30,24 @@ public class HeightStructuresCalculationTest { [Test] + public void Constructor_NullGeneralInput_ThrowsArgumentNullException() + { + // Setup & Call + TestDelegate test = () => new HeightStructuresCalculation(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("generalInputParameters", exception.ParamName); + } + + [Test] public void Constructor_DefaultPropertyValuesAreSet() { + // Setup + var generalInput = new GeneralHeightStructuresInput(); + // Call - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation(generalInput); // Assert Assert.IsInstanceOf(calculation); @@ -47,7 +62,8 @@ public void ClearOutput_Always_SetsOutputToNull() { // Setup - var calculation = new HeightStructuresCalculation + var generalInput = new GeneralHeightStructuresInput(); + var calculation = new HeightStructuresCalculation(generalInput) { Output = new HeightStructuresOutput() }; @@ -63,7 +79,8 @@ public void HasOutput_OutputNull_ReturnsFalse() { // Setup - var calculation = new HeightStructuresCalculation + var generalInput = new GeneralHeightStructuresInput(); + var calculation = new HeightStructuresCalculation(generalInput) { Output = null }; @@ -76,7 +93,8 @@ public void HasOutput_OutputSet_ReturnsTrue() { // Setup - var calculation = new HeightStructuresCalculation + var generalInput = new GeneralHeightStructuresInput(); + var calculation = new HeightStructuresCalculation(generalInput) { Output = new HeightStructuresOutput() }; @@ -89,7 +107,8 @@ public void GetObservableInput_Always_ReturnsInputParameters() { // Setup - var calculation = new HeightStructuresCalculation(); + var generalInput = new GeneralHeightStructuresInput(); + var calculation = new HeightStructuresCalculation(generalInput); // Call ICalculationInput input = calculation.GetObservableInput(); @@ -102,7 +121,8 @@ public void GetObservableOutput_Always_ReturnsOutput() { // Setup - var calculation = new HeightStructuresCalculation + var generalInput = new GeneralHeightStructuresInput(); + var calculation = new HeightStructuresCalculation(generalInput) { Output = new HeightStructuresOutput() }; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs =================================================================== diff -u -re24eab2c6007074685556ec97dbe45940a520687 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision e24eab2c6007074685556ec97dbe45940a520687) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructuresFailureMechanismTest.cs (.../HeightStructuresFailureMechanismTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -47,6 +47,7 @@ Assert.IsNotNull(failureMechanism.CalculationsGroup); CollectionAssert.IsEmpty(failureMechanism.CalculationsGroup.Children); Assert.IsNotNull(failureMechanism.NormProbabilityInput); + Assert.IsInstanceOf(failureMechanism.GeneralInput); } [Test] @@ -98,16 +99,17 @@ { // Setup var mocks = new MockRepository(); + var generalInput = new GeneralHeightStructuresInput(); var failureMechanism = new HeightStructuresFailureMechanism { CalculationsGroup = { Children = { new CalculationGroup(), - new HeightStructuresCalculation(), + new HeightStructuresCalculation(generalInput), mocks.StrictMock(), - new HeightStructuresCalculation() + new HeightStructuresCalculation(generalInput) } } }; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs =================================================================== diff -u -r255ffcdbfd4ffff68c336ad9922e6196636c2803 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs (.../HeightStructuresCalculationContextTest.cs) (revision 255ffcdbfd4ffff68c336ad9922e6196636c2803) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs (.../HeightStructuresCalculationContextTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -43,19 +43,19 @@ public void ConstructorWithData_Always_ExpectedPropertiesSet() { // Setup - var calculationMock = mocksRepository.StrictMock(); - var failureMechanismMock = mocksRepository.StrictMock(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); var assessmentSectionMock = mocksRepository.StrictMock(); mocksRepository.ReplayAll(); // Call - var context = new HeightStructuresCalculationContext(calculationMock, failureMechanismMock, assessmentSectionMock); + var context = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); // Assert Assert.IsInstanceOf>(context); Assert.IsInstanceOf>(context); - Assert.AreEqual(calculationMock, context.WrappedData); - Assert.AreEqual(failureMechanismMock, context.FailureMechanism); + Assert.AreEqual(calculation, context.WrappedData); + Assert.AreEqual(failureMechanism, context.FailureMechanism); Assert.AreEqual(assessmentSectionMock, context.AssessmentSection); mocksRepository.VerifyAll(); } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r1c8a44983627b9d580cbbeab3c8444c5ecc41524 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 1c8a44983627b9d580cbbeab3c8444c5ecc41524) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -95,8 +95,8 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var calculation = new HeightStructuresCalculation(); var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); // Call @@ -125,11 +125,12 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var calculation = new HeightStructuresCalculation + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput) { Output = new HeightStructuresOutput() }; - var failureMechanism = new HeightStructuresFailureMechanism(); + var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); // Call @@ -160,7 +161,7 @@ var treeViewControlMock = mocks.StrictMock(); var failureMechanism = new HeightStructuresFailureMechanism(); var assessmentSectionMock = mocks.StrictMock(); - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); var menuBuilderMock = mocks.StrictMock(); @@ -199,7 +200,7 @@ var treeViewControlMock = mocks.StrictMock(); var failureMechanism = new HeightStructuresFailureMechanism(); var assessmentSectionMock = mocks.StrictMock(); - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -234,8 +235,8 @@ { // Setup var group = new CalculationGroup(); - var elementToBeRemoved = new HeightStructuresCalculation(); var failureMechanism = new HeightStructuresFailureMechanism(); + var elementToBeRemoved = new HeightStructuresCalculation(failureMechanism.GeneralInput); var observerMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); var calculationContext = new HeightStructuresCalculationContext(elementToBeRemoved, @@ -250,7 +251,7 @@ mocks.ReplayAll(); group.Children.Add(elementToBeRemoved); - group.Children.Add(new HeightStructuresCalculation()); + group.Children.Add(new HeightStructuresCalculation(failureMechanism.GeneralInput)); group.Attach(observerMock); // Precondition Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r7cebb168afee29822b64f213045a21520b38ade0 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 7cebb168afee29822b64f213045a21520b38ade0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -116,7 +116,7 @@ var failureMechanism = new HeightStructuresFailureMechanism(); var group = new CalculationGroup(); var childGroup = new CalculationGroup(); - var childCalculation = new HeightStructuresCalculation(); + var childCalculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); group.Children.Add(childGroup); group.Children.Add(calculationItemMock); @@ -240,8 +240,8 @@ failureMechanism, assessmentSectionMock); var parentGroupContext = new HeightStructuresCalculationGroupContext(parentGroup, - failureMechanism, - assessmentSectionMock); + failureMechanism, + assessmentSectionMock); var treeViewControlMock = mocks.StrictMock(); var menuBuilderMock = mocks.StrictMock(); @@ -377,9 +377,9 @@ var failureMechanism = new HeightStructuresFailureMechanism(); var assessmentSectionMock = mocks.StrictMock(); var nodeData = new HeightStructuresCalculationGroupContext(group, - failureMechanism, - assessmentSectionMock); - var calculation = new HeightStructuresCalculation + failureMechanism, + assessmentSectionMock); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput) { Name = "Nieuwe berekening" }; @@ -461,7 +461,7 @@ var parentNodeData = new HeightStructuresCalculationGroupContext(parentGroup, failureMechanism, assessmentSectionMock); - var calculation = new HeightStructuresCalculation(); + var calculation = new HeightStructuresCalculation(failureMechanism.GeneralInput); observerMock.Expect(o => o.UpdateObserver()); @@ -491,4 +491,4 @@ private const int contextMenuCalculateAllIndexNestedGroup = 3; private const int contextMenuClearAllIndexNestedGroup = 4; } -} +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs =================================================================== diff -u -rb784ac8be54e88a798f4b7b7ad54ffe47b587e20 -rb60b7e12cf211bdbe11e0a54734fa097e8ef2146 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs (.../HeightStructuresInputContextTreeNodeInfoTest.cs) (revision b784ac8be54e88a798f4b7b7ad54ffe47b587e20) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresInputContextTreeNodeInfoTest.cs (.../HeightStructuresInputContextTreeNodeInfoTest.cs) (revision b60b7e12cf211bdbe11e0a54734fa097e8ef2146) @@ -78,10 +78,11 @@ public void Text_Always_ReturnsTextFromResource() { // Setup + var generalInput = new GeneralHeightStructuresInput(); var assessmentSectionMock = mocksRepository.StrictMock(); var heightStructuresInputContext = new HeightStructuresInputContext( new HeightStructuresInput(new GeneralHeightStructuresInput()), - new HeightStructuresCalculation(), + new HeightStructuresCalculation(generalInput), new HeightStructuresFailureMechanism(), assessmentSectionMock); @@ -100,9 +101,10 @@ { // Setup var assessmentSectionMock = mocksRepository.StrictMock(); + var generalInput = new GeneralHeightStructuresInput(); var heightStructuresInputContext = new HeightStructuresInputContext( new HeightStructuresInput(new GeneralHeightStructuresInput()), - new HeightStructuresCalculation(), + new HeightStructuresCalculation(generalInput), new HeightStructuresFailureMechanism(), assessmentSectionMock);