Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r6f508b75b217be46357cbf83fca6d488b35c8b51 -re0b83003c6e32087949f65ae318cf1291bb406f9 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 6f508b75b217be46357cbf83fca6d488b35c8b51) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision e0b83003c6e32087949f65ae318cf1291bb406f9) @@ -169,8 +169,8 @@ InputParameters = { Structure = new TestClosingStructure(), - HydraulicBoundaryLocation = CreateHydraulicBoundaryLocation(), - ForeshoreProfile = CreateForeshoreProfile() + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "name", 0.0, 1.1), + ForeshoreProfile = new TestForeshoreProfile() } }; @@ -698,15 +698,5 @@ Assert.AreSame(calculation, failureMechanism.SectionResults.ElementAt(0).Calculation); mockRepository.VerifyAll(); } - - private static ForeshoreProfile CreateForeshoreProfile() - { - return new ForeshoreProfile(new Point2D(0, 0), Enumerable.Empty(), new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties()); - } - - private static HydraulicBoundaryLocation CreateHydraulicBoundaryLocation() - { - return new HydraulicBoundaryLocation(0, "name", 0.0, 1.1); - } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r67fd73b4f1a8f32897b92a30489d85e8ae92b608 -re0b83003c6e32087949f65ae318cf1291bb406f9 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 67fd73b4f1a8f32897b92a30489d85e8ae92b608) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision e0b83003c6e32087949f65ae318cf1291bb406f9) @@ -19,13 +19,21 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Linq; +using Application.Ringtoets.Storage.TestUtil; +using Core.Common.Base; +using Core.Common.Base.Data; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.HydraRing.Data; using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Data.TestUtil; using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; using Ringtoets.StabilityPointStructures.Forms.PropertyClasses; @@ -104,5 +112,154 @@ mockRepository.VerifyAll(); } + + [Test] + public void Data_SetNewInputContextInstanceWithData_ReturnCorrectPropertyValues() + { + // Setup + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + new HydraulicBoundaryLocation(0, "", 0, 0) + } + }; + var assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + mockRepository.ReplayAll(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism + { + ForeshoreProfiles = + { + new TestForeshoreProfile() + }, + StabilityPointStructures = + { + new TestStabilityPointStructure() + } + }; + var calculation = new StructuresCalculation + { + InputParameters = + { + Structure = new TestStabilityPointStructure(), + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "name", 0.0, 1.1), + ForeshoreProfile = new TestForeshoreProfile() + } + }; + + var inputContext = new StabilityPointStructuresInputContext(calculation.InputParameters, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new StabilityPointStructuresInputContextProperties(); + + // Call + properties.Data = inputContext; + + // Assert + StabilityPointStructuresInput input = calculation.InputParameters; + var expectedFailureProbabilityRepairClosure = ProbabilityFormattingHelper.Format(input.FailureProbabilityRepairClosure); + var expectedProbabilityCollisionSecondaryStructure = ProbabilityFormattingHelper.Format(input.ProbabilityCollisionSecondaryStructure); + + Assert.AreEqual(input.VolumicWeightWater, properties.VolumicWeightWater); + Assert.AreSame(input.InsideWaterLevelFailureConstruction, properties.InsideWaterLevelFailureConstruction.Data); + Assert.AreSame(input.InsideWaterLevel, properties.InsideWaterLevel.Data); + Assert.AreSame(input.DrainCoefficient, properties.DrainCoefficient.Data); + Assert.AreEqual(input.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure); + Assert.AreSame(input.FlowVelocityStructureClosable, properties.FlowVelocityStructureClosable.Data); + Assert.AreEqual(input.InflowModelType, properties.InflowModelType); + Assert.AreEqual(input.LoadSchematizationType, properties.LoadSchematizationType); + Assert.AreSame(input.LevelCrestStructure, properties.LevelCrestStructure.Data); + Assert.AreSame(input.ThresholdHeightOpenWeir, properties.ThresholdHeightOpenWeir.Data); + Assert.AreSame(input.AreaFlowApertures, properties.AreaFlowApertures.Data); + Assert.AreSame(input.ConstructiveStrengthLinearLoadModel, properties.ConstructiveStrengthLinearLoadModel.Data); + Assert.AreSame(input.ConstructiveStrengthQuadraticLoadModel, properties.ConstructiveStrengthQuadraticLoadModel.Data); + Assert.AreSame(input.StabilityLinearLoadModel, properties.StabilityLinearLoadModel.Data); + Assert.AreSame(input.StabilityQuadraticLoadModel, properties.StabilityQuadraticLoadModel.Data); + Assert.AreEqual(expectedFailureProbabilityRepairClosure, properties.FailureProbabilityRepairClosure); + Assert.AreSame(input.FailureCollisionEnergy, properties.FailureCollisionEnergy.Data); + Assert.AreSame(input.ShipMass, properties.ShipMass.Data); + Assert.AreSame(input.ShipVelocity, properties.ShipVelocity.Data); + Assert.AreEqual(input.LevellingCount, properties.LevellingCount); + Assert.AreEqual(expectedProbabilityCollisionSecondaryStructure, properties.ProbabilityCollisionSecondaryStructure); + Assert.AreSame(input.BankWidth, properties.BankWidth.Data); + Assert.AreEqual(input.EvaluationLevel, properties.EvaluationLevel); + Assert.AreEqual(input.VerticalDistance, properties.VerticalDistance); + + var availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles().ToArray(); + Assert.AreEqual(1, availableForeshoreProfiles.Length); + CollectionAssert.AreEqual(failureMechanism.ForeshoreProfiles, availableForeshoreProfiles); + + var availableStructures = properties.GetAvailableStructures().ToArray(); + Assert.AreEqual(1, availableStructures.Length); + CollectionAssert.AreEqual(failureMechanism.StabilityPointStructures, availableStructures); + + mockRepository.VerifyAll(); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + const int numberOfChangedProperties = 9; + var observerMock = mockRepository.StrictMock(); + var assessmentSectionStub = mockRepository.Stub(); + + observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + + mockRepository.ReplayAll(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new StabilityPointStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new StabilityPointStructuresInputContextProperties + { + Data = inputContext + }; + + input.Attach(observerMock); + + var random = new Random(100); + double newVolumicWeightWater = random.NextDouble(); + double newFactorStormDurationOpenStructure = random.NextDouble(); + var newInflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert; + var newLoadSchematizationType = LoadSchematizationType.Quadratic; + var newLevellingCount = 2; + double newEvaluationLevel = random.NextDouble(); + double newVerticalDistance = random.NextDouble(); + + // Call + properties.VolumicWeightWater = (RoundedDouble) newVolumicWeightWater; + properties.FactorStormDurationOpenStructure = (RoundedDouble) newFactorStormDurationOpenStructure; + properties.InflowModelType = newInflowModelType; + properties.LoadSchematizationType = newLoadSchematizationType; + properties.FailureProbabilityRepairClosure = "1e-2"; + properties.LevellingCount = newLevellingCount; + properties.ProbabilityCollisionSecondaryStructure = "1e-3"; + properties.EvaluationLevel = (RoundedDouble) newEvaluationLevel; + properties.VerticalDistance = (RoundedDouble) newVerticalDistance; + + // Assert + var expectedFailureProbabilityRepairClosure = ProbabilityFormattingHelper.Format(0.01); + var expectedProbabilityCollisionSecondaryStructure = ProbabilityFormattingHelper.Format(0.001); + + Assert.AreEqual(newVolumicWeightWater, properties.VolumicWeightWater, properties.VolumicWeightWater.GetAccuracy()); + Assert.AreEqual(newFactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure, properties.FactorStormDurationOpenStructure.GetAccuracy()); + Assert.AreEqual(newInflowModelType, properties.InflowModelType); + Assert.AreEqual(newLoadSchematizationType, properties.LoadSchematizationType); + Assert.AreEqual(expectedFailureProbabilityRepairClosure, properties.FailureProbabilityRepairClosure); + Assert.AreEqual(newLevellingCount, properties.LevellingCount); + Assert.AreEqual(expectedProbabilityCollisionSecondaryStructure, properties.ProbabilityCollisionSecondaryStructure); + Assert.AreEqual(newEvaluationLevel, properties.EvaluationLevel, properties.EvaluationLevel.GetAccuracy()); + Assert.AreEqual(newVerticalDistance, properties.VerticalDistance, properties.VerticalDistance.GetAccuracy()); + + mockRepository.VerifyAll(); + } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj =================================================================== diff -u -r67fd73b4f1a8f32897b92a30489d85e8ae92b608 -re0b83003c6e32087949f65ae318cf1291bb406f9 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision 67fd73b4f1a8f32897b92a30489d85e8ae92b608) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision e0b83003c6e32087949f65ae318cf1291bb406f9) @@ -91,6 +91,10 @@ + + {03DBE353-99F7-47D6-B826-60D694FFB9AC} + Application.Ringtoets.Storage.TestUtil + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} Core.Common.Base