Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs =================================================================== diff -u -r0afc6984f0b40aa96f1929cb20e0be7402dd7fed -r1ef9d71c6daa8b7439e4289fcd889fcdd1080a44 --- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 0afc6984f0b40aa96f1929cb20e0be7402dd7fed) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 1ef9d71c6daa8b7439e4289fcd889fcdd1080a44) @@ -91,19 +91,44 @@ widthFlowApertures = new VariationCoefficientNormalDistribution(2) { - Mean = (RoundedDouble)double.NaN, - CoefficientOfVariation = (RoundedDouble)0.05 + Mean = (RoundedDouble) double.NaN, + CoefficientOfVariation = (RoundedDouble) 0.05 }; stormDuration = new VariationCoefficientLogNormalDistribution(2) { - Mean = (RoundedDouble)6.0, - CoefficientOfVariation = (RoundedDouble)0.25 + Mean = (RoundedDouble) 6.0, + CoefficientOfVariation = (RoundedDouble) 0.25 }; UpdateForeshoreProperties(); } + #region Model factors + + /// + /// Gets or sets the model factor for the super critical flow. + /// + /// Only sets the mean. + public NormalDistribution ModelFactorSuperCriticalFlow + { + get + { + return modelFactorSuperCriticalFlow; + } + set + { + modelFactorSuperCriticalFlow.Mean = value.Mean; + } + } + + #endregion + + /// + /// Synchronizes the input properties with the properties of the structure. + /// + protected abstract void UpdateStructureProperties(); + private static bool ValidProbabilityValue(double probability) { return !double.IsNaN(probability) && probability <= 1 && probability >= 0; @@ -133,6 +158,22 @@ #region Schematization /// + /// Gets or sets the structure. + /// + public T Structure + { + get + { + return structure; + } + set + { + structure = value; + UpdateStructureProperties(); + } + } + + /// /// Gets or sets the orientation of the normal of the structure. /// [degrees] /// @@ -271,26 +312,6 @@ #endregion - #region Model factors - - /// - /// Gets or sets the model factor for the super critical flow. - /// - /// Only sets the mean. - public NormalDistribution ModelFactorSuperCriticalFlow - { - get - { - return modelFactorSuperCriticalFlow; - } - set - { - modelFactorSuperCriticalFlow.Mean = value.Mean; - } - } - - #endregion - #region Foreshore Profile /// Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs =================================================================== diff -u -r0afc6984f0b40aa96f1929cb20e0be7402dd7fed -r1ef9d71c6daa8b7439e4289fcd889fcdd1080a44 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision 0afc6984f0b40aa96f1929cb20e0be7402dd7fed) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision 1ef9d71c6daa8b7439e4289fcd889fcdd1080a44) @@ -93,6 +93,7 @@ Assert.IsInstanceOf(input); Assert.IsInstanceOf(input); + Assert.IsNull(input.Structure); Assert.IsNull(input.HydraulicBoundaryLocation); AssertEqualValue(double.NaN, input.StructureNormalOrientation); @@ -482,6 +483,31 @@ AssertDistributionCorrectlySet(input.StormDuration, distributionToSet, expectedDistribution); } + [Test] + public void Properties_Structure_UpdateValuesAccordingly() + { + // Setup + var structure = new SimpleStructure(new StructureBase.ConstructionProperties + { + Name = "", + Location = new Point2D(0, 0), + Id = "id" + }); + + var input = new SimpleStructuresInput(); + + // Precondition + Assert.IsNull(input.Structure); + Assert.IsFalse(input.Updated); + + // Call + input.Structure = structure; + + // Assert + Assert.AreSame(structure, input.Structure); + Assert.IsTrue(input.Updated); + } + private static void AssertEqualValue(double expectedValue, RoundedDouble actualValue) { Assert.AreEqual(expectedValue, actualValue, actualValue.GetAccuracy()); @@ -499,6 +525,20 @@ DistributionAssert.AreEqual(expectedDistribution, distributionToAssert); } - private class SimpleStructuresInput : StructuresInputBase {} + private class SimpleStructuresInput : StructuresInputBase + { + protected override void UpdateStructureProperties() + { + Updated = true; + } + + public bool Updated { get; private set; } + } + + private class SimpleStructure : StructureBase + { + public SimpleStructure(ConstructionProperties constructionProperties) : base(constructionProperties) {} + public SimpleStructure(string name, string id, Point2D location, double structureNormalOrientation) : base(name, id, location, structureNormalOrientation) {} + } } } \ No newline at end of file