Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismProperties.cs =================================================================== diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -r9310242df6e13b00a66aa170a44303345482aea1 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismProperties.cs (.../MacroStabilityOutwardsFailureMechanismProperties.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismProperties.cs (.../MacroStabilityOutwardsFailureMechanismProperties.cs) (revision 9310242df6e13b00a66aa170a44303345482aea1) @@ -24,6 +24,7 @@ using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Probability; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.Input; @@ -36,6 +37,7 @@ /// public class MacroStabilityOutwardsFailureMechanismProperties : ObjectProperties { + private readonly IAssessmentSection assessmentSection; private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; private const int groupPropertyIndex = 3; @@ -50,14 +52,22 @@ /// Creates a new instance of . /// /// The instance to show the properties of. - /// Thrown when input parameter is null. - public MacroStabilityOutwardsFailureMechanismProperties(MacroStabilityOutwardsFailureMechanism data) + /// The assessment section the data belongs to. + /// Thrown when any parameter is null. + public MacroStabilityOutwardsFailureMechanismProperties(MacroStabilityOutwardsFailureMechanism data, IAssessmentSection assessmentSection) { if (data == null) { throw new ArgumentNullException(nameof(data)); } + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + this.assessmentSection = assessmentSection; + Data = data; } @@ -188,7 +198,7 @@ { get { - return new RoundedDouble(2, data.MacroStabilityOutwardsProbabilityAssessmentInput.SectionLength); + return new RoundedDouble(2, assessmentSection.ReferenceLine.Length); } } @@ -202,7 +212,7 @@ get { MacroStabilityOutwardsProbabilityAssessmentInput probabilityAssessmentInput = data.MacroStabilityOutwardsProbabilityAssessmentInput; - return new RoundedDouble(2, probabilityAssessmentInput.GetN(probabilityAssessmentInput.SectionLength)); + return new RoundedDouble(2, probabilityAssessmentInput.GetN(assessmentSection.ReferenceLine.Length)); } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r4b37694736a8ccec603ce7f9b71e6c095186b25d -r9310242df6e13b00a66aa170a44303345482aea1 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 4b37694736a8ccec603ce7f9b71e6c095186b25d) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 9310242df6e13b00a66aa170a44303345482aea1) @@ -324,7 +324,7 @@ }; yield return new PropertyInfo { - CreateInstance = context => new MacroStabilityOutwardsFailureMechanismProperties(context.WrappedData) + CreateInstance = context => new MacroStabilityOutwardsFailureMechanismProperties(context.WrappedData, context.Parent) }; yield return new PropertyInfo { Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -r9310242df6e13b00a66aa170a44303345482aea1 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismPropertiesTest.cs (.../MacroStabilityOutwardsFailureMechanismPropertiesTest.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAlone/MacroStabilityOutwardsFailureMechanismPropertiesTest.cs (.../MacroStabilityOutwardsFailureMechanismPropertiesTest.cs) (revision 9310242df6e13b00a66aa170a44303345482aea1) @@ -26,6 +26,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Data.StandAlone; @@ -47,29 +48,50 @@ private const int nPropertyIndex = 8; [Test] - public void Constructor_DataIsNull_ThrowArgumentNullException() + public void Constructor_DataNull_ThrowArgumentNullException() { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + // Call - TestDelegate test = () => new MacroStabilityOutwardsFailureMechanismProperties(null); + TestDelegate test = () => new MacroStabilityOutwardsFailureMechanismProperties(null, assessmentSection); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("data", paramName); + mocks.VerifyAll(); } [Test] + public void Constructor_AssessmentSectionNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityOutwardsFailureMechanismProperties(new MacroStabilityOutwardsFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] [TestCase(true)] [TestCase(false)] public void Constructor_ExpectedValues(bool isRelevant) { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityOutwardsFailureMechanism { IsRelevant = isRelevant }; // Call - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>(properties); @@ -83,26 +105,31 @@ Assert.AreEqual(probabilityAssessmentInput.A, properties.A); Assert.AreEqual(probabilityAssessmentInput.B, properties.B); Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); - Assert.AreEqual(probabilityAssessmentInput.GetN(probabilityAssessmentInput.SectionLength), + Assert.AreEqual(probabilityAssessmentInput.GetN(assessmentSection.ReferenceLine.Length), properties.N, properties.N.GetAccuracy()); Assert.AreEqual(2, properties.SectionLength.NumberOfDecimalPlaces); - Assert.AreEqual(probabilityAssessmentInput.SectionLength, + Assert.AreEqual(assessmentSection.ReferenceLine.Length, properties.SectionLength, properties.SectionLength.GetAccuracy()); + mocks.VerifyAll(); } [Test] public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityOutwardsFailureMechanism { IsRelevant = true }; // Call - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -172,19 +199,24 @@ "N* [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling (afgerond).", true); + mocks.VerifyAll(); } [Test] public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityOutwardsFailureMechanism { IsRelevant = false }; // Call - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -219,6 +251,7 @@ "Is relevant", "Geeft aan of dit toetsspoor relevant is of niet.", true); + mocks.VerifyAll(); } [Test] @@ -231,12 +264,13 @@ { // Setup var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); var observer = mocks.StrictMock(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); failureMechanism.Attach(observer); - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Call TestDelegate call = () => properties.A = value; @@ -257,13 +291,14 @@ { // Setup var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); failureMechanism.Attach(observer); - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Call properties.A = value; @@ -279,11 +314,15 @@ public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityOutwardsFailureMechanism { IsRelevant = isRelevant }; - var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism); + var properties = new MacroStabilityOutwardsFailureMechanismProperties(failureMechanism, assessmentSection); // Call & Assert Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); @@ -298,6 +337,7 @@ Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.N))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + mocks.VerifyAll(); } } } \ No newline at end of file