Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -ra4412c73942b2a5e083506a0afda6595a5eddce7 -r7a8c2847a1bfce3af38bb493f799a6c005638c4b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision a4412c73942b2a5e083506a0afda6595a5eddce7) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 7a8c2847a1bfce3af38bb493f799a6c005638c4b) @@ -231,20 +231,20 @@ } [PropertyOrder(phreaticLevelExitPropertyIndex)] - [TypeConverter(typeof(NormalDistributionDesignVariableTypeConverter))] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_HydraulicData))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_PhreaticLevelExit_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_PhreaticLevelExit_Description))] - public DesignVariable PhreaticLevelExit + public NormalDistributionDesignVariableProperties PhreaticLevelExit { get { - return PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(data.WrappedData); + return new NormalDistributionDesignVariableProperties(DistributionPropertiesReadOnly.None, + PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(data.WrappedData), + data.PipingCalculation, + data.WrappedData, + propertyChangeHandler); } - set - { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.PhreaticLevelExit = v, value.Distribution); - } } [PropertyOrder(piezometricHeadExitPropertyIndex)] Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -ra4412c73942b2a5e083506a0afda6595a5eddce7 -r7a8c2847a1bfce3af38bb493f799a6c005638c4b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision a4412c73942b2a5e083506a0afda6595a5eddce7) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 7a8c2847a1bfce3af38bb493f799a6c005638c4b) @@ -211,8 +211,7 @@ PropertyDescriptor phreaticLevelExitProperty = dynamicProperties[expectedPhreaticLevelExitPropertyIndex]; Assert.IsNotNull(phreaticLevelExitProperty); - Assert.IsInstanceOf(phreaticLevelExitProperty.Converter); - Assert.IsFalse(phreaticLevelExitProperty.IsReadOnly); + Assert.IsInstanceOf(phreaticLevelExitProperty.Converter); Assert.AreEqual(hydraulicDataCategory, phreaticLevelExitProperty.Category); Assert.AreEqual("Polderpeil [m+NAP]", phreaticLevelExitProperty.DisplayName); Assert.AreEqual("Polderpeil.", phreaticLevelExitProperty.Description); @@ -432,8 +431,10 @@ PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); // Call & Assert - Assert.AreSame(inputParameters.PhreaticLevelExit, properties.PhreaticLevelExit.Distribution); - Assert.AreSame(inputParameters.DampingFactorExit, properties.DampingFactorExit.Data); + Assert.AreEqual(inputParameters.PhreaticLevelExit.Mean, properties.PhreaticLevelExit.Mean); + Assert.AreEqual(inputParameters.PhreaticLevelExit.StandardDeviation, properties.PhreaticLevelExit.StandardDeviation); + Assert.AreEqual(inputParameters.DampingFactorExit.Mean, properties.DampingFactorExit.Mean); + Assert.AreEqual(inputParameters.DampingFactorExit.StandardDeviation, properties.DampingFactorExit.StandardDeviation); Assert.AreEqual(inputParameters.ThicknessCoverageLayer.Mean, properties.ThicknessCoverageLayer.Distribution.Mean); Assert.AreEqual(inputParameters.ThicknessCoverageLayer.StandardDeviation, properties.ThicknessCoverageLayer.Distribution.StandardDeviation); Assert.AreEqual(inputParameters.EffectiveThicknessCoverageLayer.Mean, properties.EffectiveThicknessCoverageLayer.Distribution.Mean); @@ -524,7 +525,8 @@ properties.StochasticSoilProfile = soilProfile; properties.DampingFactorExit.Mean = dampingFactorExit.Distribution.Mean; properties.DampingFactorExit.StandardDeviation = dampingFactorExit.Distribution.StandardDeviation; - properties.PhreaticLevelExit = phreaticLevelExit; + properties.PhreaticLevelExit.Mean = phreaticLevelExit.Distribution.Mean; + properties.PhreaticLevelExit.StandardDeviation = phreaticLevelExit.Distribution.StandardDeviation; // Assert Assert.AreEqual(assessmentLevel, inputParameters.AssessmentLevel.Value); @@ -611,18 +613,28 @@ } [Test] - public void PhreaticLevelExit_SetValidValue_SetsValueAndUpdatesObservers() + public void PhreaticLevelExitMean_SetValidValue_SetsValueAndUpdatesObservers() { // Setup - var distribution = new NormalDistribution(3); - var newPhreaticLevelExit = new NormalDistributionDesignVariable(distribution); + var mean = new RoundedDouble(2, 2); var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit = newPhreaticLevelExit, distribution, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.Mean = mean, mean, calculation); } [Test] + public void PhreaticLevelExitStandardDeviation_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var standardDeviation = new RoundedDouble(2, 2); + var calculation = new PipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.StandardDeviation = standardDeviation, standardDeviation, calculation); + } + + [Test] public void EntryPoinL_SetValidValue_SetsValueAndUpdatesObservers() { // Setup @@ -1397,7 +1409,6 @@ { // Given var mocks = new MockRepository(); - var typeDescriptorContext = mocks.StrictMock(); var assessmentSection = mocks.Stub(); PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); @@ -1416,17 +1427,18 @@ PipingInputContextProperties contextProperties = new PipingInputContextProperties(context, handler); inputParameters.HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(1.0); - DesignVariable phreaticLevelExitProperty = contextProperties.PhreaticLevelExit; - DynamicPropertyBag dynamicPropertyBag = new DynamicPropertyBag(contextProperties); - typeDescriptorContext.Expect(tdc => tdc.Instance).Return(dynamicPropertyBag).Repeat.Twice(); - typeDescriptorContext.Stub(tdc => tdc.PropertyDescriptor).Return(dynamicPropertyBag.GetProperties()["PhreaticLevelExit"]); + NormalDistributionDesignVariableProperties phreaticLevelExitProperty = contextProperties.PhreaticLevelExit; mocks.ReplayAll(); - PropertyDescriptorCollection properties = new NormalDistributionDesignVariableTypeConverter().GetProperties(typeDescriptorContext, phreaticLevelExitProperty); - Assert.NotNull(properties); - // When - properties[propertyIndexToChange].SetValue(phreaticLevelExitProperty, (RoundedDouble) 2.3); + if (propertyIndexToChange == 1) + { + phreaticLevelExitProperty.Mean = (RoundedDouble) 2.3; + } + else if (propertyIndexToChange == 2) + { + phreaticLevelExitProperty.StandardDeviation = (RoundedDouble) 2.3; + } // Then Assert.IsFalse(double.IsNaN(inputParameters.PiezometricHeadExit)); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs =================================================================== diff -u -r60d95df18eb252bf99dff07a76d9660f331c92c2 -r7a8c2847a1bfce3af38bb493f799a6c005638c4b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (.../NormalDistributionDesignVariableTypeConverterTest.cs) (revision 60d95df18eb252bf99dff07a76d9660f331c92c2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (.../NormalDistributionDesignVariableTypeConverterTest.cs) (revision 7a8c2847a1bfce3af38bb493f799a6c005638c4b) @@ -201,69 +201,6 @@ mocks.VerifyAll(); } - #region Integration tests - - [Test] - [TestCase(1)] - [TestCase(2)] - public void GivenPipingInputParameterContextPropertiesInDynamicPropertyBag_WhenSettingNewValue_ThenPipingInputUpdatesObservers(int propertyIndexToChange) - { - // Scenario - var mocks = new MockRepository(); - var typeDescriptorContextMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); - - var inputParameters = new PipingInput(new GeneralPipingInput()); - var inputParametersContext = new PipingInputContext(inputParameters, - calculationItem, - Enumerable.Empty(), - Enumerable.Empty(), - failureMechanism, - assessmentSectionMock); - - var handler = new CalculationInputPropertyChangeHandler(); - var inputParameterContextProperties = new PipingInputContextProperties(inputParametersContext, handler); - - PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(inputParameterContextProperties).Find("PhreaticLevelExit", false); - var dynamicPropertyBag = new DynamicPropertyBag(inputParameterContextProperties); - - typeDescriptorContextMock.Expect(tdc => tdc.Instance).Return(dynamicPropertyBag).Repeat.Twice(); - typeDescriptorContextMock.Stub(tdc => tdc.PropertyDescriptor).Return(propertyDescriptor); - mocks.ReplayAll(); - - inputParameters.Attach(observer); - - DesignVariable phreaticLevelExit = inputParameterContextProperties.PhreaticLevelExit; - PropertyDescriptorCollection properties = new NormalDistributionDesignVariableTypeConverter().GetProperties(typeDescriptorContextMock, phreaticLevelExit); - - // Precondition - Assert.IsNotNull(properties); - - // Event - const double newValue = 2.3; - properties[propertyIndexToChange].SetValue(phreaticLevelExit, (RoundedDouble) newValue); - - // Result - switch (propertyIndexToChange) - { - case 1: - Assert.AreEqual(newValue, inputParameters.PhreaticLevelExit.Mean.Value); - break; - case 2: - Assert.AreEqual(newValue, inputParameters.PhreaticLevelExit.StandardDeviation.Value); - break; - } - mocks.VerifyAll(); - } - - #endregion - private class ClassWithReadOnlyDesignVariable { public ClassWithReadOnlyDesignVariable()