Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingSemiProbabilisticDesignValueFactory.cs =================================================================== diff -u -r8ab8e38488feea6de520f6d58ec664acb28ee8a1 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingSemiProbabilisticDesignValueFactory.cs (.../PipingSemiProbabilisticDesignValueFactory.cs) (revision 8ab8e38488feea6de520f6d58ec664acb28ee8a1) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingSemiProbabilisticDesignValueFactory.cs (.../PipingSemiProbabilisticDesignValueFactory.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -8,22 +8,6 @@ /// public static class PipingSemiProbabilisticDesignValueFactory { - #region Uplift parameters - - /// - /// Creates the design variable for . - /// - public static DesignVariable GetSandParticlesVolumicWeight(PipingData pipingData) - { - return new DesignVariable - { - Distribution = pipingData.SandParticlesVolumicWeight, - Percentile = 0.05 - }; - } - - #endregion - #region General parameters /// Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs =================================================================== diff -u -r8ab8e38488feea6de520f6d58ec664acb28ee8a1 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs (.../PipingData.cs) (revision 8ab8e38488feea6de520f6d58ec664acb28ee8a1) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingData.cs (.../PipingData.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -20,8 +20,10 @@ // Defaults as they have been defined in 'functional design semi-probabilistic assessments 1209431-008-ZWS-0009 Version 2 Final' UpliftModelFactor = 1.0; + SellmeijerModelFactor = 1.0; WaterVolumetricWeight = 10.0; WhitesDragCoefficient = 0.25; + SandParticlesVolumicWeight = 16.5; WaterKinematicViscosity = 1.33e-6; Gravity = 9.81; MeanDiameter70 = 2.08e-4; @@ -32,7 +34,6 @@ PhreaticLevelExit = new NormalDistribution(); DampingFactorExit = new LognormalDistribution { Mean = 1.0 }; ThicknessCoverageLayer = new LognormalDistribution(); - SandParticlesVolumicWeight = new ShiftedLognormalDistribution { Mean = 16.5 }; SeepageLength = new LognormalDistribution(); Diameter70 = new LognormalDistribution(); DarcyPermeability = new LognormalDistribution(); @@ -56,6 +57,12 @@ public double WaterVolumetricWeight { get; set; } /// + /// Gets or sets the (lowerbound) volumic weight of sand grain material of a sand layer under water. + /// [kN/m³] + /// + public double SandParticlesVolumicWeight { get; set; } + + /// /// Gets or sets the White's drag coefficient. /// public double WhitesDragCoefficient { get; set; } @@ -157,12 +164,6 @@ public LognormalDistribution ThicknessCoverageLayer { get; set; } /// - /// Gets or sets the (lowerbound) volumic weight of sand grain material of a sand layer under water. - /// [kN/m³] - /// - public ShiftedLognormalDistribution SandParticlesVolumicWeight { get; set; } - - /// /// Gets or sets the damping factor at the exit point. /// public LognormalDistribution DampingFactorExit { get; set; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilLayer.cs =================================================================== diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -26,12 +26,14 @@ public double? IsAquifer { get; set; } /// - /// Gets or sets the above phreatic level for the . + /// Gets or sets the volumic weight of the above the phreatic level. + /// [kN/m³] /// public double? AbovePhreaticLevel { get; set; } /// - /// Gets or sets the below phreatic level for the . + /// Gets or sets the volumic weight of the below the phreatic level. + /// [kN/m³] /// public double? BelowPhreaticLevel { get; set; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs =================================================================== diff -u -r8ab8e38488feea6de520f6d58ec664acb28ee8a1 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs (.../PipingCalculationInputsProperties.cs) (revision 8ab8e38488feea6de520f6d58ec664acb28ee8a1) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationInputsProperties.cs (.../PipingCalculationInputsProperties.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -3,6 +3,8 @@ using System.Drawing.Design; using Core.Common.Gui; using Core.Common.Utils; + +using Ringtoets.Piping.Calculation.Piping; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.Probabilistics; using Ringtoets.Piping.Forms.PresentationObjects; @@ -95,36 +97,36 @@ } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_DampingFactorExit_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_DampingFactorExit_Description")] - public LognormalDistribution DampingFactorExit + public DesignVariable DampingFactorExit { get { - return data.PipingData.DampingFactorExit; + return PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(data.PipingData); } set { - data.PipingData.DampingFactorExit = value; + data.PipingData.DampingFactorExit = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } - [TypeConverter(typeof(NormalDistributionTypeConverter))] + [TypeConverter(typeof(NormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_PhreaticLevelExit_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_PhreaticLevelExit_Description")] - public NormalDistribution PhreaticLevelExit + public DesignVariable PhreaticLevelExit { get { - return data.PipingData.PhreaticLevelExit; + return PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(data.PipingData); } set { - data.PipingData.PhreaticLevelExit = value; + data.PipingData.PhreaticLevelExit = (NormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } @@ -156,19 +158,19 @@ } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_ThicknessCoverageLayer_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_ThicknessCoverageLayer_Description")] - public LognormalDistribution ThicknessCoverageLayer + public DesignVariable ThicknessCoverageLayer { get { - return data.PipingData.ThicknessCoverageLayer; + return PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(data.PipingData); } set { - data.PipingData.ThicknessCoverageLayer = value; + data.PipingData.ThicknessCoverageLayer = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } @@ -205,28 +207,27 @@ } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_SeepageLength_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_SeepageLength_Description")] - public LognormalDistribution SeepageLength + public DesignVariable SeepageLength { get { - return data.PipingData.SeepageLength; + return PipingSemiProbabilisticDesignValueFactory.GetSeepageLength(data.PipingData); } set { - data.PipingData.SeepageLength = value; + data.PipingData.SeepageLength = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } - [TypeConverter(typeof(ShiftedLognormalDistributionTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_SandParticlesVolumicWeight_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_SandParticlesVolumicWeight_Description")] - public ShiftedLognormalDistribution SandParticlesVolumicWeight + public double SandParticlesVolumicWeight { get { @@ -255,36 +256,36 @@ } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_Diameter70_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_Diameter70_Description")] - public LognormalDistribution Diameter70 + public DesignVariable Diameter70 { get { - return data.PipingData.Diameter70; + return PipingSemiProbabilisticDesignValueFactory.GetDiameter70(data.PipingData); } set { - data.PipingData.Diameter70 = value; + data.PipingData.Diameter70 = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_DarcyPermeability_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_DarcyPermeability_Description")] - public LognormalDistribution DarcyPermeability + public DesignVariable DarcyPermeability { get { - return data.PipingData.DarcyPermeability; + return PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(data.PipingData); } set { - data.PipingData.DarcyPermeability = value; + data.PipingData.DarcyPermeability = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } @@ -321,19 +322,19 @@ } } - [TypeConverter(typeof(LognormalDistributionTypeConverter))] + [TypeConverter(typeof(LognormalDistributionDesignVariableTypeConverter))] [ResourcesCategory(typeof(Resources), "Categories_General")] [ResourcesDisplayName(typeof(Resources), "PipingData_ThicknessAquiferLayer_DisplayName")] [ResourcesDescription(typeof(Resources), "PipingData_ThicknessAquiferLayer_Description")] - public LognormalDistribution ThicknessAquiferLayer + public DesignVariable ThicknessAquiferLayer { get { - return data.PipingData.ThicknessAquiferLayer; + return PipingSemiProbabilisticDesignValueFactory.GetThicknessAquiferLayer(data.PipingData); } set { - data.PipingData.ThicknessAquiferLayer = value; + data.PipingData.ThicknessAquiferLayer = (LognormalDistribution)value.Distribution; data.PipingData.NotifyObservers(); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -r21c58fc28e5675736f50be6e06b2605120991478 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 21c58fc28e5675736f50be6e06b2605120991478) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -74,11 +74,13 @@ - - - - - + + + + + + + @@ -110,6 +112,10 @@ Core.Common.Version False + + {d64e4f0e-e341-496f-82b2-941ad202b4e3} + Ringtoets.Piping.Calculation + {10B8D63D-87E8-46DF-ACA9-A8CF22EE8FB5} Ringtoets.Piping.Service Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/DesignVariableTypeConverter.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,150 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Linq.Expressions; +using Core.Common.Base; +using Core.Common.Utils.PropertyBag.Dynamic; + +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors; + +namespace Ringtoets.Piping.Forms.TypeConverters +{ + /// + /// Base class for shared implementation of to provide probabilistic + /// distributions to the property editor. + /// + /// Type of distributionci + public abstract class DesignVariableTypeConverter : TypeConverter where T:IDistribution + { + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string)) + { + var designVariable = (DesignVariable)value; + var variablesText = string.Join(", ", Parameters.Select(p => p.GetSummary((T)designVariable.Distribution, culture))); + return String.Format("{0} ({1})", designVariable.GetDesignValue(), variablesText); + } + return base.ConvertTo(context, culture, value, destinationType); + } + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + IObservable observableParent = GetObservableOwnerOfDistribution(context); + + var designVariable = (DesignVariable)value; + PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(designVariable.Distribution); + var properties = new PropertyDescriptor[Parameters.Length+2]; + properties[0] = new SimpleReadonlyPropertyDescriptorItem("Type verdeling", "De soort kansverdeling waarin deze parameter in gedefiniëerd wordt.", "DistributionType", DistributionName); + for (int i = 0; i < Parameters.Length; i++) + { + properties[i+1] = CreatePropertyDescriptor(propertyDescriptorCollection, Parameters[i], observableParent); + } + properties[Parameters.Length + 1] = new SimpleReadonlyPropertyDescriptorItem("Rekenwaarde", "De representatieve waarde die gebruikt wordt door de berekening.", "DesignValue", designVariable.GetDesignValue()); + + return new PropertyDescriptorCollection(properties); + } + + /// + /// Gets the name of the distribution. + /// + protected abstract string DistributionName { get; } + + /// + /// Gets all parameters available for the given distribution. + /// + protected abstract ParameterDefinition[] Parameters { get; } + + private static PropertyDescriptor CreatePropertyDescriptor(PropertyDescriptorCollection originalProperties, ParameterDefinition parameter, IObservable observableParent) + { + PropertyDescriptor originalMeanPropertyDescriptor = originalProperties.Find(parameter.PropertyName, false); + var reroutedPropertyDescriptor = new RoutedPropertyDescriptor(originalMeanPropertyDescriptor, o => ((DesignVariable)o).Distribution); + return new TextPropertyDescriptorDecorator(reroutedPropertyDescriptor, + parameter.Symbol, + parameter.Description) + { + ObservableParent = observableParent, + }; + } + + private static IObservable GetObservableOwnerOfDistribution(ITypeDescriptorContext context) + { + if (context == null) + { + return null; + } + // Sadly, we need this hack in order to update the correct class + var dynamicPropertyBag = context.Instance as DynamicPropertyBag; + if (dynamicPropertyBag == null) + { + return null; + } + + // Note: If this type converter is going to be reused for other classes, we + // might want to reconsider how we want to propagate IObservable updates! + var pipingCalculationInputProperties = dynamicPropertyBag.WrappedObject as PipingCalculationInputsProperties; + return pipingCalculationInputProperties != null ? + ((PipingCalculationInputs)pipingCalculationInputProperties.Data).PipingData : + null; + } + + /// + /// A generic parameter description class. + /// + /// Type of object which as the parameter. + protected class ParameterDefinition + { + /// + /// Instantiates a new instance of for a + /// given parameter. + /// + /// The parameter expression. + public ParameterDefinition(Expression> expression) + { + PropertyName = ((MemberExpression)expression.Body).Member.Name; + GetValue = expression.Compile(); + } + + /// + /// The symbol of name of the parameter. + /// + public string Symbol { get; set; } + + /// + /// Name of the property holding the parameter + /// + public string PropertyName { get; private set; } + + /// + /// Method to retrieve the value of the parameter from a distribution. + /// + public Func GetValue { get; private set; } + + /// + /// Description text of the parameter. + /// + public string Description { get; set; } + + /// + /// Retrieves the 'symbol = value' text. + /// + /// The distribution of evaluate. + /// The culture used to print text in. + /// The summay text of the parameter. + public string GetSummary(DistributionType distribution, CultureInfo culture) + { + return String.Format("{0} = {1}", + Symbol, + GetValue(distribution).ToString(culture)); + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/LognormalDistributionDesignVariableTypeConverter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/LognormalDistributionDesignVariableTypeConverter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/LognormalDistributionDesignVariableTypeConverter.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,59 @@ +using System; +using System.ComponentModel; + +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.Forms.PropertyClasses; + +namespace Ringtoets.Piping.Forms.TypeConverters +{ + /// + /// A implementation for + /// properties. + /// + /// This class has been designed to be used in . + /// If its reused somewhere else, change notification might not work properly. + public sealed class LognormalDistributionDesignVariableTypeConverter : DesignVariableTypeConverter + { + private readonly ParameterDefinition[] parameters; + + /// + /// Initializes a new instance of the class. + /// + public LognormalDistributionDesignVariableTypeConverter() + { + var lowerCaseDistributionName = DistributionName.ToLower(); + parameters = new[] + { + new ParameterDefinition(d => d.Mean) + { + Symbol = Resources.Probabilistics_Mean_Symbol, + Description = String.Format(Resources.Probabilistics_Mean_description_for_Distribution_0_, + lowerCaseDistributionName) + }, + new ParameterDefinition(d => d.StandardDeviation) + { + Symbol = Resources.Probabilistics_StandardDeviation_Symbol, + Description = String.Format(Resources.Probabilistics_StandardDeviation_description_for_Distribution_0_, + lowerCaseDistributionName) + } + }; + } + + protected override string DistributionName + { + get + { + return Resources.LognormalDistribution_DisplayName; + } + } + + protected override ParameterDefinition[] Parameters + { + get + { + return parameters; + } + } + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/LognormalDistributionTypeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/NormalDistributionDesignVariableTypeConverter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/NormalDistributionDesignVariableTypeConverter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/NormalDistributionDesignVariableTypeConverter.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,59 @@ +using System; +using System.ComponentModel; + +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.Forms.PropertyClasses; + +namespace Ringtoets.Piping.Forms.TypeConverters +{ + /// + /// A implementation for + /// properties. + /// + /// This class has been designed to be used in . + /// If its reused somewhere else, change notification might not work properly. + public sealed class NormalDistributionDesignVariableTypeConverter : DesignVariableTypeConverter + { + private readonly ParameterDefinition[] parameters; + + /// + /// Initializes a new instance of the class. + /// + public NormalDistributionDesignVariableTypeConverter() + { + var lowerCaseDistributionName = DistributionName.ToLower(); + parameters = new[] + { + new ParameterDefinition(d => d.Mean) + { + Symbol = Resources.Probabilistics_Mean_Symbol, + Description = String.Format(Resources.Probabilistics_Mean_description_for_Distribution_0_, + lowerCaseDistributionName) + }, + new ParameterDefinition(d => d.StandardDeviation) + { + Symbol = Resources.Probabilistics_StandardDeviation_Symbol, + Description = String.Format(Resources.Probabilistics_StandardDeviation_description_for_Distribution_0_, + lowerCaseDistributionName) + } + }; + } + + protected override string DistributionName + { + get + { + return Resources.NormalDistribution_DisplayName; + } + } + + protected override ParameterDefinition[] Parameters + { + get + { + return parameters; + } + } + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/NormalDistributionTypeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/ProbabilisticDistributionTypeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptor.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptor.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptor.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,67 @@ +using System; +using System.ComponentModel; + +namespace Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors +{ + public class RoutedPropertyDescriptor : PropertyDescriptor + { + private readonly Func rerouteToActualPropertyOwner; + private readonly PropertyDescriptor originalPropertyDescriptor; + + public RoutedPropertyDescriptor(PropertyDescriptor descr, Func routerFunction) + : base(descr) + { + originalPropertyDescriptor = descr; + rerouteToActualPropertyOwner = routerFunction; + } + + public override bool CanResetValue(object component) + { + return originalPropertyDescriptor.CanResetValue(rerouteToActualPropertyOwner(component)); + } + + public override object GetValue(object component) + { + return originalPropertyDescriptor.GetValue(rerouteToActualPropertyOwner(component)); + } + + public override void ResetValue(object component) + { + originalPropertyDescriptor.ResetValue(rerouteToActualPropertyOwner(component)); + } + + public override void SetValue(object component, object value) + { + originalPropertyDescriptor.SetValue(rerouteToActualPropertyOwner(component), value); + } + + public override bool ShouldSerializeValue(object component) + { + return originalPropertyDescriptor.ShouldSerializeValue(rerouteToActualPropertyOwner(component)); + } + + public override Type ComponentType + { + get + { + return originalPropertyDescriptor.ComponentType; + } + } + + public override bool IsReadOnly + { + get + { + return originalPropertyDescriptor.IsReadOnly; + } + } + + public override Type PropertyType + { + get + { + return originalPropertyDescriptor.PropertyType; + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptor.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptor.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptor.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,82 @@ +using System; +using System.ComponentModel; + +namespace Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors +{ + /// + /// This class defines a simple readonly property item that actually isn't an actual + /// property of an object, but a standalone piece of data. Because the piece of data + /// does not belong to some component, the data is readonly and cannot be set or changed. + /// + public class SimpleReadonlyPropertyDescriptorItem : PropertyDescriptor + { + private readonly object valueObject; + + /// + /// Initializes a new instance of the class. + /// + /// The display name of the data. + /// The descriptive text associated with the data. + /// The name of the 'property', allowing it searched for in collections. + /// The value that should be shown in the value field. + public SimpleReadonlyPropertyDescriptorItem(string displayName, string description, string id, object value) : + base(id, new Attribute[] + { + new DisplayNameAttribute(displayName), + new DescriptionAttribute(description), + new ReadOnlyAttribute(true) + }) + { + valueObject = value; + } + + public override Type ComponentType + { + get + { + throw new NotImplementedException(); + } + } + + public override bool IsReadOnly + { + get + { + return true; + } + } + + public override Type PropertyType + { + get + { + return valueObject.GetType(); + } + } + + public override bool CanResetValue(object component) + { + return false; + } + + public override object GetValue(object component) + { + return valueObject; + } + + public override void ResetValue(object component) + { + throw new NotImplementedException(); + } + + public override void SetValue(object component, object value) + { + throw new NotImplementedException(); + } + + public override bool ShouldSerializeValue(object component) + { + return false; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecorator.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecorator.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecorator.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,111 @@ +using System; +using System.ComponentModel; + +using Core.Common.Base; + +namespace Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors +{ + /// + /// This class allows for overriding and + /// of a given . + /// + public class TextPropertyDescriptorDecorator : PropertyDescriptor + { + private readonly string displayNameOverride; + private readonly string descriptionOverride; + private readonly PropertyDescriptor wrappedDescriptor; + + /// + /// Initializes a new instance of the class. + /// + /// The property descriptor being decorated. + /// The custom display name. + /// The custom description. + public TextPropertyDescriptorDecorator(PropertyDescriptor descr, string customDisplayName, string customDescription) + : base(descr) + { + displayNameOverride = customDisplayName; + descriptionOverride = customDescription; + wrappedDescriptor = descr; + } + + public override string DisplayName + { + get + { + return displayNameOverride; + } + } + + public override string Description + { + get + { + return descriptionOverride; + } + } + + /// + /// Gets or sets the observable object whose should notify all observers when + /// is called. + /// + public IObservable ObservableParent { get; set; } + + #region Members delegated to wrapped descriptor + + public override bool CanResetValue(object component) + { + return wrappedDescriptor.CanResetValue(component); + } + + public override object GetValue(object component) + { + return wrappedDescriptor.GetValue(component); + } + + public override void ResetValue(object component) + { + wrappedDescriptor.ResetValue(component); + } + + public override void SetValue(object component, object value) + { + wrappedDescriptor.SetValue(component, value); + if (ObservableParent != null) + { + ObservableParent.NotifyObservers(); + } + } + + public override bool ShouldSerializeValue(object component) + { + return wrappedDescriptor.ShouldSerializeValue(component); + } + + public override Type ComponentType + { + get + { + return wrappedDescriptor.ComponentType; + } + } + + public override bool IsReadOnly + { + get + { + return wrappedDescriptor.IsReadOnly; + } + } + + public override Type PropertyType + { + get + { + return wrappedDescriptor.PropertyType; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverter.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverter.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverter.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,64 @@ +using System; +using System.ComponentModel; + +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.Properties; +using Ringtoets.Piping.Forms.PropertyClasses; + +namespace Ringtoets.Piping.Forms.TypeConverters +{ + /// + /// A implementation for + /// properties. + /// + /// This class has been designed to be used in . + /// If its reused somewhere else, change notification might not work properly. + public sealed class ShiftedLognormalDistributionDesignVariableTypeConverter : DesignVariableTypeConverter + { + private readonly ParameterDefinition[] parameters; + + /// + /// Initializes a new instance of the class. + /// + public ShiftedLognormalDistributionDesignVariableTypeConverter() + { + var lowerCaseDistributionName = DistributionName.ToLower(); + parameters = new[] + { + new ParameterDefinition(d => d.Mean) + { + Symbol = Resources.Probabilistics_Mean_Symbol, + Description = String.Format(Resources.Probabilistics_Mean_description_for_Distribution_0_, + lowerCaseDistributionName) + }, + new ParameterDefinition(d => d.StandardDeviation) + { + Symbol = Resources.Probabilistics_StandardDeviation_Symbol, + Description = String.Format(Resources.Probabilistics_StandardDeviation_description_for_Distribution_0_, + lowerCaseDistributionName) + }, + new ParameterDefinition(d => d.Shift) + { + Symbol = Resources.Probabilistics_Shift_Symbol, + Description = Resources.Probabilistics_Shift_Description + }, + }; + } + + protected override string DistributionName + { + get + { + return Resources.ShiftedLognormalDistribution_DisplayName; + } + } + + protected override ParameterDefinition[] Parameters + { + get + { + return parameters; + } + } + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/ShiftedLognormalDistributionTypeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/TypeConverters/TextPropertyDescriptorDecorator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs =================================================================== diff -u -raa882371e29e0c3c8c64d4bb31d802b98ca44142 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision aa882371e29e0c3c8c64d4bb31d802b98ca44142) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -94,7 +94,7 @@ pipingData.SellmeijerModelFactor, pipingData.SellmeijerReductionFactor, PipingSemiProbabilisticDesignValueFactory.GetSeepageLength(pipingData).GetDesignValue(), - PipingSemiProbabilisticDesignValueFactory.GetSandParticlesVolumicWeight(pipingData).GetDesignValue(), + pipingData.SandParticlesVolumicWeight, pipingData.WhitesDragCoefficient, PipingSemiProbabilisticDesignValueFactory.GetDiameter70(pipingData).GetDesignValue(), PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(pipingData).GetDesignValue(), Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingSemiProbabilisticDesignValueFactoryTest.cs =================================================================== diff -u -r8ab8e38488feea6de520f6d58ec664acb28ee8a1 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingSemiProbabilisticDesignValueFactoryTest.cs (.../PipingSemiProbabilisticDesignValueFactoryTest.cs) (revision 8ab8e38488feea6de520f6d58ec664acb28ee8a1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingSemiProbabilisticDesignValueFactoryTest.cs (.../PipingSemiProbabilisticDesignValueFactoryTest.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -54,24 +54,6 @@ #endregion - #region Uplift parameters - - [Test] - public void GetSandParticlesVolumicWeight_ValidPipingData_CreateDesignVariableForSandParticlesVolumicWeight() - { - // Setup - var pipingData = new PipingData(); - - // Call - var dampingFactorExit = PipingSemiProbabilisticDesignValueFactory.GetSandParticlesVolumicWeight(pipingData); - - // Assert - Assert.AreSame(pipingData.SandParticlesVolumicWeight, dampingFactorExit.Distribution); - Assert.AreEqual(0.05, dampingFactorExit.Percentile); - } - - #endregion - #region Piping parameters [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingDataTest.cs =================================================================== diff -u -r8ab8e38488feea6de520f6d58ec664acb28ee8a1 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingDataTest.cs (.../PipingDataTest.cs) (revision 8ab8e38488feea6de520f6d58ec664acb28ee8a1) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingDataTest.cs (.../PipingDataTest.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -35,10 +35,6 @@ Assert.IsInstanceOf(defaultConstructed.ThicknessCoverageLayer); Assert.AreEqual(0, defaultConstructed.ThicknessCoverageLayer.Mean); Assert.AreEqual(1, defaultConstructed.ThicknessCoverageLayer.StandardDeviation); - Assert.IsInstanceOf(defaultConstructed.SandParticlesVolumicWeight); - Assert.AreEqual(16.5, defaultConstructed.SandParticlesVolumicWeight.Mean); - Assert.AreEqual(1, defaultConstructed.SandParticlesVolumicWeight.StandardDeviation); - Assert.AreEqual(0, defaultConstructed.SandParticlesVolumicWeight.Shift); Assert.IsInstanceOf(defaultConstructed.SeepageLength); Assert.AreEqual(0, defaultConstructed.SeepageLength.Mean); Assert.AreEqual(1, defaultConstructed.SeepageLength.StandardDeviation); @@ -55,16 +51,17 @@ Assert.AreEqual(0, defaultConstructed.PiezometricHeadExit); Assert.AreEqual(0, defaultConstructed.PiezometricHeadPolder); Assert.AreEqual(0, defaultConstructed.AssessmentLevel); - Assert.AreEqual(0, defaultConstructed.SellmeijerModelFactor); Assert.IsNull(defaultConstructed.SurfaceLine); Assert.IsNull(defaultConstructed.SoilProfile); Assert.AreEqual(1.0, defaultConstructed.UpliftModelFactor); + Assert.AreEqual(1, defaultConstructed.SellmeijerModelFactor); Assert.AreEqual(0.5, defaultConstructed.CriticalHeaveGradient); Assert.AreEqual(0.3, defaultConstructed.SellmeijerReductionFactor); Assert.AreEqual(9.81, defaultConstructed.Gravity); Assert.AreEqual(1.33e-6, defaultConstructed.WaterKinematicViscosity); Assert.AreEqual(10.0, defaultConstructed.WaterVolumetricWeight); + Assert.AreEqual(16.5, defaultConstructed.SandParticlesVolumicWeight); Assert.AreEqual(0.25, defaultConstructed.WhitesDragCoefficient); Assert.AreEqual(37, defaultConstructed.BeddingAngle); Assert.AreEqual(2.08e-4, defaultConstructed.MeanDiameter70); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationInputsNodePresenterTest.cs =================================================================== diff -u -raa882371e29e0c3c8c64d4bb31d802b98ca44142 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationInputsNodePresenterTest.cs (.../PipingCalculationInputsNodePresenterTest.cs) (revision aa882371e29e0c3c8c64d4bb31d802b98ca44142) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/NodePresenters/PipingCalculationInputsNodePresenterTest.cs (.../PipingCalculationInputsNodePresenterTest.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -475,7 +475,7 @@ pipingData.PhreaticLevelExit.Mean = validPipingInput.PhreaticLevelExit; pipingData.PiezometricHeadExit = validPipingInput.PiezometricHeadExit; pipingData.PiezometricHeadPolder = validPipingInput.PiezometricHeadPolder; - pipingData.SandParticlesVolumicWeight.Mean = validPipingInput.SandParticlesVolumicWeight; + pipingData.SandParticlesVolumicWeight = validPipingInput.SandParticlesVolumicWeight; pipingData.SeepageLength.Mean = validPipingInput.SeepageLength; pipingData.SellmeijerModelFactor = validPipingInput.SellmeijerModelFactor; pipingData.SellmeijerReductionFactor = validPipingInput.SellmeijerReductionFactor; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationInputsPropertiesTest.cs =================================================================== diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationInputsPropertiesTest.cs (.../PipingCalculationInputsPropertiesTest.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationInputsPropertiesTest.cs (.../PipingCalculationInputsPropertiesTest.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -58,31 +58,14 @@ // Call & Assert Assert.AreEqual(name, properties.Name); - Assert.AreEqual(pipingData.PhreaticLevelExit.Mean, properties.PhreaticLevelExit.Mean); - Assert.AreEqual(pipingData.PhreaticLevelExit.StandardDeviation, properties.PhreaticLevelExit.StandardDeviation); - - Assert.AreEqual(pipingData.DampingFactorExit.Mean, properties.DampingFactorExit.Mean); - Assert.AreEqual(pipingData.DampingFactorExit.StandardDeviation, properties.DampingFactorExit.StandardDeviation); - - Assert.AreEqual(pipingData.ThicknessCoverageLayer.Mean, properties.ThicknessCoverageLayer.Mean); - Assert.AreEqual(pipingData.ThicknessCoverageLayer.StandardDeviation, properties.ThicknessCoverageLayer.StandardDeviation); - - Assert.AreEqual(pipingData.SeepageLength.Mean, properties.SeepageLength.Mean); - Assert.AreEqual(pipingData.SeepageLength.StandardDeviation, properties.SeepageLength.StandardDeviation); - - Assert.AreEqual(pipingData.Diameter70.Mean, properties.Diameter70.Mean); - Assert.AreEqual(pipingData.Diameter70.StandardDeviation, properties.Diameter70.StandardDeviation); - - Assert.AreEqual(pipingData.DarcyPermeability.Mean, properties.DarcyPermeability.Mean); - Assert.AreEqual(pipingData.DarcyPermeability.StandardDeviation, properties.DarcyPermeability.StandardDeviation); - - Assert.AreEqual(pipingData.ThicknessAquiferLayer.Mean, properties.ThicknessAquiferLayer.Mean); - Assert.AreEqual(pipingData.ThicknessAquiferLayer.StandardDeviation, properties.ThicknessAquiferLayer.StandardDeviation); - - Assert.AreEqual(pipingData.SandParticlesVolumicWeight.Mean, properties.SandParticlesVolumicWeight.Mean); - Assert.AreEqual(pipingData.SandParticlesVolumicWeight.StandardDeviation, properties.SandParticlesVolumicWeight.StandardDeviation); - Assert.AreEqual(pipingData.SandParticlesVolumicWeight.Shift, properties.SandParticlesVolumicWeight.Shift); - + Assert.AreSame(pipingData.PhreaticLevelExit, properties.PhreaticLevelExit.Distribution); + Assert.AreSame(pipingData.DampingFactorExit, properties.DampingFactorExit.Distribution); + Assert.AreSame(pipingData.ThicknessCoverageLayer, properties.ThicknessCoverageLayer.Distribution); + Assert.AreSame(pipingData.SeepageLength, properties.SeepageLength.Distribution); + Assert.AreSame(pipingData.Diameter70, properties.Diameter70.Distribution); + Assert.AreSame(pipingData.DarcyPermeability, properties.DarcyPermeability.Distribution); + Assert.AreSame(pipingData.ThicknessAquiferLayer, properties.ThicknessAquiferLayer.Distribution); + Assert.AreEqual(pipingData.UpliftModelFactor, properties.UpliftModelFactor); Assert.AreEqual(pipingData.PiezometricHeadExit, properties.PiezometricHeadExit); Assert.AreEqual(pipingData.PiezometricHeadPolder, properties.PiezometricHeadPolder); @@ -94,6 +77,7 @@ Assert.AreEqual(pipingData.Gravity, properties.Gravity); Assert.AreEqual(pipingData.WaterKinematicViscosity, properties.WaterKinematicViscosity); Assert.AreEqual(pipingData.WaterVolumetricWeight, properties.WaterVolumetricWeight); + Assert.AreEqual(pipingData.SandParticlesVolumicWeight, properties.SandParticlesVolumicWeight); Assert.AreEqual(pipingData.WhitesDragCoefficient, properties.WhitesDragCoefficient); Assert.AreEqual(pipingData.BeddingAngle, properties.BeddingAngle); Assert.AreEqual(pipingData.MeanDiameter70, properties.MeanDiameter70); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -r21c58fc28e5675736f50be6e06b2605120991478 -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 21c58fc28e5675736f50be6e06b2605120991478) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -64,10 +64,12 @@ - - - - + + + + + + Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionDesignVariableTypeConverterTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,177 @@ +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Utils.PropertyBag.Dynamic; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.Forms.TypeConverters; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters +{ + [TestFixture] + public class LognormalDistributionDesignVariableTypeConverterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new LognormalDistributionDesignVariableTypeConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void CanConvertTo_DestinationTypeIsString_ReturnTrue() + { + // Setup + var converter = new LognormalDistributionDesignVariableTypeConverter(); + + // Call + var canConvert = converter.CanConvertTo(typeof(string)); + + // Assert + Assert.IsTrue(canConvert); + } + + [Test] + public void ConvertTo_DestinationTypeIsString_ReturnLognormalDistributionSpecs() + { + // Setup + var distribution = new LognormalDistribution + { + Mean = 1.1, + StandardDeviation = 2.2 + }; + var designVariable = new DesignVariable { Distribution = distribution }; + + var converter = new LognormalDistributionDesignVariableTypeConverter(); + + // Call + var result = converter.ConvertTo(designVariable, typeof(string)); + + // Assert + var expectedText = string.Format("{0} (\u03BC = {1}, \u03C3 = {2})", + designVariable.GetDesignValue(), distribution.Mean, distribution.StandardDeviation); + Assert.AreEqual(expectedText, result); + } + + [Test] + public void GetPropertiesSupported_Always_ReturnTrue() + { + // Setup + var converter = new LognormalDistributionDesignVariableTypeConverter(); + + // Call + var hasSubProperties = converter.GetPropertiesSupported(); + + // Assert + Assert.IsTrue(hasSubProperties); + } + + [Test] + public void GetProperties_Always_ReturnMeanAndStandardDeviation() + { + // Setup + var distribution = new LognormalDistribution(); + var designVariable = new DesignVariable{ Distribution = distribution }; + var converter = new LognormalDistributionDesignVariableTypeConverter(); + + // Call + var properties = converter.GetProperties(designVariable); + + // Assert + Assert.IsNotNull(properties); + Assert.AreEqual(4, properties.Count); + + var distributionTypePropertyDescriptor = properties[0]; + Assert.AreEqual(typeof(string), distributionTypePropertyDescriptor.PropertyType); + Assert.IsTrue(distributionTypePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Type verdeling", distributionTypePropertyDescriptor.DisplayName); + Assert.AreEqual("De soort kansverdeling waarin deze parameter in gedefiniëerd wordt.", distributionTypePropertyDescriptor.Description); + Assert.AreEqual("DistributionType", distributionTypePropertyDescriptor.Name); + Assert.AreEqual("Lognormale verdeling", distributionTypePropertyDescriptor.GetValue(new object())); + + var meanPropertyDescriptor = properties[1]; + Assert.AreEqual(distribution.GetType(), meanPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType); + Assert.IsFalse(meanPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03BC", meanPropertyDescriptor.DisplayName); + Assert.AreEqual("De gemiddelde waarde van de lognormale verdeling.", meanPropertyDescriptor.Description); + + var stdPropertyDescriptor = properties[2]; + Assert.AreEqual(distribution.GetType(), stdPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), stdPropertyDescriptor.PropertyType); + Assert.IsFalse(stdPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03C3", stdPropertyDescriptor.DisplayName); + Assert.AreEqual("De standaardafwijking van de lognormale verdeling.", stdPropertyDescriptor.Description); + + var designValuePropertyDescriptor = properties[3]; + Assert.AreEqual(typeof(double), designValuePropertyDescriptor.PropertyType); + Assert.IsTrue(designValuePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Rekenwaarde", designValuePropertyDescriptor.DisplayName); + Assert.AreEqual("De representatieve waarde die gebruikt wordt door de berekening.", designValuePropertyDescriptor.Description); + Assert.AreEqual("DesignValue", designValuePropertyDescriptor.Name); + Assert.AreEqual(designVariable.GetDesignValue(), designValuePropertyDescriptor.GetValue(new object())); + } + + #region Integration tests + + [Test] + [TestCase(1)] + [TestCase(2)] + public void GivenContextOfPipingCalculationInputsPropertiesWrappedInDynamicPropertyBag_WhenSettingNewValue_ThenPipingDataNotifiedObserversOfChange(int propertyIndexToChange) + { + // Scenario + var pipingData = new PipingData(); + var calculationInputs = new PipingCalculationInputs + { + PipingData = pipingData + }; + var calculationInputsProperties = new PipingCalculationInputsProperties + { + Data = calculationInputs + }; + var dynamicPropertyBag = new DynamicPropertyBag(calculationInputsProperties); + + var mocks = new MockRepository(); + var typeDescriptorContextMock = mocks.StrictMock(); + typeDescriptorContextMock.Expect(tdc => tdc.Instance).Return(dynamicPropertyBag); + + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + pipingData.Attach(observer); + + DesignVariable dampingFactorExit = calculationInputsProperties.DampingFactorExit; + var properties = new LognormalDistributionDesignVariableTypeConverter().GetProperties(typeDescriptorContextMock, dampingFactorExit); + + // Precondition + Assert.IsNotNull(properties); + + // Event + properties[propertyIndexToChange].SetValue(dampingFactorExit, 2.3); + + // Result + switch (propertyIndexToChange) + { + case 1: + Assert.AreEqual(2.3, pipingData.DampingFactorExit.Mean); + break; + case 2: + Assert.AreEqual(2.3, pipingData.DampingFactorExit.StandardDeviation); + break; + } + mocks.VerifyAll(); + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/LognormalDistributionTypeConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionDesignVariableTypeConverterTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,176 @@ +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Utils.PropertyBag.Dynamic; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.Forms.PropertyClasses; +using Ringtoets.Piping.Forms.TypeConverters; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters +{ + [TestFixture] + public class NormalDistributionDesignVariableTypeConverterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new NormalDistributionDesignVariableTypeConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void CanConvertTo_DestinationTypeIsString_ReturnTrue() + { + // Setup + var converter = new NormalDistributionDesignVariableTypeConverter(); + + // Call + var canConvert = converter.CanConvertTo(typeof(string)); + + // Assert + Assert.IsTrue(canConvert); + } + + [Test] + public void ConvertTo_DestinationTypeIsString_ReturnNormalDistributionSpecs() + { + // Setup + var distribution = new NormalDistribution + { + Mean = 1.1, + StandardDeviation = 2.2 + }; + var designVariable = new DesignVariable{ Distribution = distribution }; + var converter = new NormalDistributionDesignVariableTypeConverter(); + + // Call + var result = converter.ConvertTo(designVariable, typeof(string)); + + // Assert + var expectedText = string.Format("{0} (\u03BC = {1}, \u03C3 = {2})", + designVariable.GetDesignValue(), distribution.Mean, distribution.StandardDeviation); + Assert.AreEqual(expectedText, result); + } + + [Test] + public void GetPropertiesSupported_Always_ReturnTrue() + { + // Setup + var converter = new NormalDistributionDesignVariableTypeConverter(); + + // Call + var hasSubProperties = converter.GetPropertiesSupported(); + + // Assert + Assert.IsTrue(hasSubProperties); + } + + [Test] + public void GetProperties_Always_ReturnMeanAndStandardDeviation() + { + // Setup + var distribution = new NormalDistribution(); + var designVariable = new DesignVariable { Distribution = distribution }; + var converter = new NormalDistributionDesignVariableTypeConverter(); + + // Call + var properties = converter.GetProperties(designVariable); + + // Assert + Assert.IsNotNull(properties); + Assert.AreEqual(4, properties.Count); + + var distributionTypePropertyDescriptor = properties[0]; + Assert.AreEqual(typeof(string), distributionTypePropertyDescriptor.PropertyType); + Assert.IsTrue(distributionTypePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Type verdeling", distributionTypePropertyDescriptor.DisplayName); + Assert.AreEqual("De soort kansverdeling waarin deze parameter in gedefiniëerd wordt.", distributionTypePropertyDescriptor.Description); + Assert.AreEqual("DistributionType", distributionTypePropertyDescriptor.Name); + Assert.AreEqual("Normale verdeling", distributionTypePropertyDescriptor.GetValue(new object())); + + var meanPropertyDescriptor = properties[1]; + Assert.AreEqual(distribution.GetType(), meanPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType); + Assert.IsFalse(meanPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03BC", meanPropertyDescriptor.DisplayName); + Assert.AreEqual("De gemiddelde waarde van de normale verdeling.", meanPropertyDescriptor.Description); + + var stdPropertyDescriptor = properties[2]; + Assert.AreEqual(distribution.GetType(), stdPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), stdPropertyDescriptor.PropertyType); + Assert.IsFalse(stdPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03C3", stdPropertyDescriptor.DisplayName); + Assert.AreEqual("De standaardafwijking van de normale verdeling.", stdPropertyDescriptor.Description); + + var designValuePropertyDescriptor = properties[3]; + Assert.AreEqual(typeof(double), designValuePropertyDescriptor.PropertyType); + Assert.IsTrue(designValuePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Rekenwaarde", designValuePropertyDescriptor.DisplayName); + Assert.AreEqual("De representatieve waarde die gebruikt wordt door de berekening.", designValuePropertyDescriptor.Description); + Assert.AreEqual("DesignValue", designValuePropertyDescriptor.Name); + Assert.AreEqual(designVariable.GetDesignValue(), designValuePropertyDescriptor.GetValue(new object())); + } + + #region Integration tests + + [Test] + [TestCase(1)] + [TestCase(2)] + public void GivenContextOfPipingCalculationInputsPropertiesWrappedInDynamicPropertyBag_WhenSettingNewValue_ThenPipingDataNotifiedObserversOfChange(int propertyIndexToChange) + { + // Scenario + var pipingData = new PipingData(); + var calculationInputs = new PipingCalculationInputs + { + PipingData = pipingData + }; + var calculationInputsProperties = new PipingCalculationInputsProperties + { + Data = calculationInputs + }; + var dynamicPropertyBag = new DynamicPropertyBag(calculationInputsProperties); + + var mocks = new MockRepository(); + var typeDescriptorContextMock = mocks.StrictMock(); + typeDescriptorContextMock.Expect(tdc => tdc.Instance).Return(dynamicPropertyBag); + + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + pipingData.Attach(observer); + + DesignVariable designVariable = calculationInputsProperties.PhreaticLevelExit; + var properties = new NormalDistributionDesignVariableTypeConverter().GetProperties(typeDescriptorContextMock, designVariable); + + // Precondition + Assert.IsNotNull(properties); + + // Event + properties[propertyIndexToChange].SetValue(designVariable, 2.3); + + // Result + switch (propertyIndexToChange) + { + case 1: + Assert.AreEqual(2.3, pipingData.PhreaticLevelExit.Mean); + break; + case 2: + Assert.AreEqual(2.3, pipingData.PhreaticLevelExit.StandardDeviation); + break; + } + mocks.VerifyAll(); + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/NormalDistributionTypeConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/RoutedPropertyDescriptorTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,160 @@ +using System.ComponentModel; + +using NUnit.Framework; + +using Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters.PropertyDescriptors +{ + [TestFixture] + public class RoutedPropertyDescriptorTest + { + [Test] + public void ParameteredConstructpr_ExpecedValues() + { + // Setup + var a = new TestA(); + var propertyDescription = TypeDescriptor.GetProperties(a.Child)[0]; + + // Call + var routedPropertyDescriptor = new RoutedPropertyDescriptor(propertyDescription, o => ((TestA)o).Child); + + // Assert + Assert.AreEqual(propertyDescription.ComponentType, routedPropertyDescriptor.ComponentType); + Assert.AreEqual(propertyDescription.IsReadOnly, routedPropertyDescriptor.IsReadOnly); + Assert.AreEqual(propertyDescription.PropertyType, routedPropertyDescriptor.PropertyType); + + Assert.AreEqual(propertyDescription.Name, routedPropertyDescriptor.Name); + Assert.AreEqual(propertyDescription.Attributes, routedPropertyDescriptor.Attributes); + Assert.AreEqual(propertyDescription.Category, routedPropertyDescriptor.Category); + Assert.AreEqual(propertyDescription.Converter, routedPropertyDescriptor.Converter); + Assert.AreEqual(propertyDescription.Description, routedPropertyDescriptor.Description); + Assert.AreEqual(propertyDescription.DesignTimeOnly, routedPropertyDescriptor.DesignTimeOnly); + Assert.AreEqual(propertyDescription.DisplayName, routedPropertyDescriptor.DisplayName); + Assert.AreEqual(propertyDescription.IsBrowsable, routedPropertyDescriptor.IsBrowsable); + Assert.AreEqual(propertyDescription.IsLocalizable, routedPropertyDescriptor.IsLocalizable); + Assert.AreEqual(propertyDescription.SerializationVisibility, routedPropertyDescriptor.SerializationVisibility); + Assert.AreEqual(propertyDescription.SupportsChangeEvents, routedPropertyDescriptor.SupportsChangeEvents); + } + + [Test] + public void CanResetValue_Always_DeferToWrappedPropertyDescriptorButReroutingObjectArgument() + { + // Setup + var a = new TestA(); + var propertyDescription = TypeDescriptor.GetProperties(a.Child)[0]; + + var routedPropertyDescriptor = new RoutedPropertyDescriptor(propertyDescription, o => ((TestA)o).Child); + + // Call + var result = routedPropertyDescriptor.CanResetValue(a); + + // Assert + Assert.AreEqual(propertyDescription.CanResetValue(a.Child), result); + } + + [Test] + public void GetValue_Always_DeferToWrappedPropertyDescriptorButReroutingObjectArgument() + { + // Setup + var a = new TestA(); + var propertyDescription = TypeDescriptor.GetProperties(a.Child)[0]; + + var routedPropertyDescriptor = new RoutedPropertyDescriptor(propertyDescription, o => ((TestA)o).Child); + + // Call + var result = routedPropertyDescriptor.GetValue(a); + + // Assert + Assert.AreEqual(propertyDescription.GetValue(a.Child), result); + } + + [Test] + public void ResetValue_Always_DeferToWrappedPropertyDescriptorButReroutingObjectArgument() + { + // Setup + const double originalPropertyValue = 1.1; + var a = new TestA + { + Child = + { + Value = originalPropertyValue + } + }; + + PropertyDescriptor getSetProperty = TypeDescriptor.GetProperties(a.Child)[0]; + + getSetProperty.ResetValue(a.Child); + var expectedPropertyValueAfterReset = a.Child.Value; + + var routedPropertyDescriptor = new RoutedPropertyDescriptor(getSetProperty, o => ((TestA)o).Child); + a.Child.Value = originalPropertyValue; + + // Call + routedPropertyDescriptor.ResetValue(a); + + // Assert + Assert.AreEqual(expectedPropertyValueAfterReset, a.Child.Value); + } + + [Test] + public void SetValue_Always_DeferToWrappedPropertyDescriptorButReroutingObjectArgument() + { + // Setup + const double originalPropertyValue = 1.1; + const double newValue = 2.2; + var a = new TestA + { + Child = + { + Value = originalPropertyValue + } + }; + + PropertyDescriptor getSetProperty = TypeDescriptor.GetProperties(a.Child)[0]; + + getSetProperty.SetValue(a.Child, newValue); + var expectedPropertyValueAfterReset = a.Child.Value; + + var routedPropertyDescriptor = new RoutedPropertyDescriptor(getSetProperty, o => ((TestA)o).Child); + a.Child.Value = originalPropertyValue; + + // Call + routedPropertyDescriptor.SetValue(a, newValue); + + // Assert + Assert.AreEqual(expectedPropertyValueAfterReset, a.Child.Value); + } + + [Test] + public void ShouldSerializeValue_Always_DeferToWrappedPropertyDescriptorButReroutingObjectArgument() + { + // Setup + var a = new TestA(); + var propertyDescription = TypeDescriptor.GetProperties(a.Child)[0]; + + var routedPropertyDescriptor = new RoutedPropertyDescriptor(propertyDescription, o => ((TestA)o).Child); + + // Call + var result = routedPropertyDescriptor.ShouldSerializeValue(a); + + // Assert + Assert.AreEqual(propertyDescription.ShouldSerializeValue(a.Child), result); + } + + private class TestA + { + public TestA() + { + Child = new TestB(); + } + + public TestB Child { get; set; } + } + + private class TestB + { + public double Value { get; set; } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptorItemTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptorItemTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/SimpleReadonlyPropertyDescriptorItemTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,75 @@ +using System.ComponentModel; + +using NUnit.Framework; + +using Ringtoets.Piping.Forms.TypeConverters; +using Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters +{ + [TestFixture] + public class SimpleReadonlyPropertyDescriptorItemTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + const string displayName = "A"; + const string description = "B"; + const string id = "C"; + const double value = 1.2345; + + // Call + var propertyItem = new SimpleReadonlyPropertyDescriptorItem(displayName, description, id, value); + + // Assert + Assert.IsInstanceOf(propertyItem); + Assert.IsTrue(propertyItem.IsReadOnly); + Assert.IsTrue(propertyItem.IsBrowsable); + Assert.AreEqual(id, propertyItem.Name); + Assert.AreEqual(displayName, propertyItem.DisplayName); + Assert.AreEqual(description, propertyItem.Description); + Assert.AreEqual(value.GetType(), propertyItem.PropertyType); + } + + [Test] + public void CanResetValue_Always_ReturnFalse() + { + // Setup + var propertyItem = new SimpleReadonlyPropertyDescriptorItem("A", "B", "C", "D"); + + // Call + var resetAllowed = propertyItem.CanResetValue(new object()); + + // Assert + Assert.IsFalse(resetAllowed); + } + + [Test] + public void GetValue_Always_ReturnValueArgument() + { + // Setup + var valueArgument = new object(); + var propertyItem = new SimpleReadonlyPropertyDescriptorItem("A", "B", "C", valueArgument); + + // Call + var value = propertyItem.GetValue(new object()); + + // Assert + Assert.AreSame(valueArgument, value); + } + + [Test] + public void ShouldSerializeValue_Always_ReturnFalse() + { + // Setup + var propertyItem = new SimpleReadonlyPropertyDescriptorItem("A", "B", "C", "D"); + + // Call + var serializationRequired = propertyItem.ShouldSerializeValue(new object()); + + // Assert + Assert.IsFalse(serializationRequired); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecoratorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecoratorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/PropertyDescriptors/TextPropertyDescriptorDecoratorTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,197 @@ +using System.ComponentModel; + +using Core.Common.Base; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Piping.Forms.TypeConverters; +using Ringtoets.Piping.Forms.TypeConverters.PropertyDescriptors; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters.PropertyDescriptors +{ + [TestFixture] + public class TextPropertyDescriptorDecoratorTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + const string displayName = ""; + const string description = ""; + + var target = new ClassWithDoubleProperty(); + var properties = TypeDescriptor.GetProperties(target); + + PropertyDescriptor getSetProperty = properties[0]; + + // Call + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, displayName, description); + + // Assert + Assert.AreEqual(displayName, wrappedProperty.DisplayName); + Assert.AreEqual(description, wrappedProperty.Description); + + Assert.AreEqual(getSetProperty.ComponentType, wrappedProperty.ComponentType); + Assert.AreEqual(getSetProperty.IsReadOnly, wrappedProperty.IsReadOnly); + Assert.AreEqual(getSetProperty.PropertyType, wrappedProperty.PropertyType); + Assert.AreEqual(getSetProperty.Name, wrappedProperty.Name); + Assert.AreEqual(getSetProperty.Attributes, wrappedProperty.Attributes); + Assert.AreEqual(getSetProperty.Category, wrappedProperty.Category); + Assert.AreEqual(getSetProperty.Converter, wrappedProperty.Converter); + Assert.AreEqual(getSetProperty.DesignTimeOnly, wrappedProperty.DesignTimeOnly); + Assert.AreEqual(getSetProperty.IsBrowsable, wrappedProperty.IsBrowsable); + Assert.AreEqual(getSetProperty.IsLocalizable, wrappedProperty.IsLocalizable); + Assert.AreEqual(getSetProperty.SerializationVisibility, wrappedProperty.SerializationVisibility); + Assert.AreEqual(getSetProperty.SupportsChangeEvents, wrappedProperty.SupportsChangeEvents); + + Assert.IsNull(wrappedProperty.ObservableParent); + } + + [Test] + public void CanResetValue_Always_DelegateToWrappedPropertyDescriptor() + { + // Setup + var component = new ClassWithDoubleProperty(); + var properties = TypeDescriptor.GetProperties(component); + + PropertyDescriptor getSetProperty = properties[0]; + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null); + + // Call + var result = wrappedProperty.CanResetValue(component); + + // Assert + Assert.AreEqual(getSetProperty.CanResetValue(component), result); + } + + [Test] + public void GetValue_Always_DelegateToWrappedPropertyDescriptor() + { + // Setup + var component = new ClassWithDoubleProperty + { + GetSetProperty = 1.1 + }; + + var properties = TypeDescriptor.GetProperties(component); + PropertyDescriptor getSetProperty = properties[0]; + + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null); + + // Call + var result = wrappedProperty.GetValue(component); + + // Assert + Assert.AreEqual(getSetProperty.GetValue(component), result); + Assert.AreEqual(component.GetSetProperty, result); + } + + [Test] + public void ResetValue_Always_DelegateToWrappedPropertyDescriptor() + { + // Setup + const double originalPropertyValue = 1.1; + var component = new ClassWithDoubleProperty + { + GetSetProperty = originalPropertyValue + }; + + var properties = TypeDescriptor.GetProperties(component); + PropertyDescriptor getSetProperty = properties[0]; + + getSetProperty.ResetValue(component); + var expectedPropertyValueAfterReset = component.GetSetProperty; + + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null); + component.GetSetProperty = originalPropertyValue; + + // Call + wrappedProperty.ResetValue(component); + + // Assert + Assert.AreEqual(expectedPropertyValueAfterReset, component.GetSetProperty); + } + + [Test] + public void SetValue_Always_DelegateToWrappedPropertyDescriptor() + { + // Setup + const double originalPropertyValue = 1.1; + const double newValue = 2.2; + var component = new ClassWithDoubleProperty + { + GetSetProperty = originalPropertyValue + }; + + var properties = TypeDescriptor.GetProperties(component); + PropertyDescriptor getSetProperty = properties[0]; + + getSetProperty.SetValue(component, newValue); + var expectedPropertyValueAfterReset = component.GetSetProperty; + + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null); + component.GetSetProperty = originalPropertyValue; + + // Call + wrappedProperty.SetValue(component, newValue); + + // Assert + Assert.AreEqual(expectedPropertyValueAfterReset, component.GetSetProperty); + } + + [Test] + public void SetValue_ObservableParentProvided_NotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + const double originalPropertyValue = 1.1; + const double newValue = 2.2; + var component = new ClassWithDoubleProperty + { + GetSetProperty = originalPropertyValue + }; + + var properties = TypeDescriptor.GetProperties(component); + PropertyDescriptor getSetProperty = properties[0]; + + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null) + { + ObservableParent = observable + }; + + // Call + wrappedProperty.SetValue(component, newValue); + + // Assert + mocks.VerifyAll(); + } + + [Test] + public void ShouldSerializeValue_Always_DelegateToWrappedPropertyDescriptor() + { + // Setup + var component = new ClassWithDoubleProperty(); + var properties = TypeDescriptor.GetProperties(component); + + PropertyDescriptor getSetProperty = properties[0]; + var wrappedProperty = new TextPropertyDescriptorDecorator(getSetProperty, null, null); + + // Call + var result = wrappedProperty.ShouldSerializeValue(component); + + // Assert + Assert.AreEqual(getSetProperty.ShouldSerializeValue(component), result); + } + + private class ClassWithDoubleProperty + { + public double GetSetProperty { get; set; } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionDesignVariableTypeConverterTest.cs (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -0,0 +1,125 @@ +using System.ComponentModel; + +using NUnit.Framework; + +using Ringtoets.Piping.Data.Probabilistics; +using Ringtoets.Piping.Forms.TypeConverters; + +namespace Ringtoets.Piping.Forms.Test.TypeConverters +{ + [TestFixture] + public class ShiftedLognormalDistributionDesignVariableTypeConverterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void CanConvertTo_DestinationTypeIsString_ReturnTrue() + { + // Setup + var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter(); + + // Call + var canConvert = converter.CanConvertTo(typeof(string)); + + // Assert + Assert.IsTrue(canConvert); + } + + [Test] + public void ConvertTo_DestinationTypeIsString_ReturnShiftedLognormalDistributionSpecs() + { + // Setup + var distribution = new ShiftedLognormalDistribution + { + Mean = 1.1, + StandardDeviation = 2.2, + Shift = 3.3 + }; + var designVariable = new DesignVariable { Distribution = distribution }; + var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter(); + + // Call + var result = converter.ConvertTo(designVariable, typeof(string)); + + // Assert + var expectedText = string.Format("{0} (\u03BC = {1}, \u03C3 = {2}, Verschuiving = {3})", + designVariable.GetDesignValue(), distribution.Mean, distribution.StandardDeviation, distribution.Shift); + Assert.AreEqual(expectedText, result); + } + + [Test] + public void GetPropertiesSupported_Always_ReturnTrue() + { + // Setup + var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter(); + + // Call + var hasSubProperties = converter.GetPropertiesSupported(); + + // Assert + Assert.IsTrue(hasSubProperties); + } + + [Test] + public void GetProperties_Always_ReturnMeanAndStandardDeviation() + { + // Setup + var distribution = new ShiftedLognormalDistribution(); + var designVariable = new DesignVariable { Distribution = distribution }; + var converter = new ShiftedLognormalDistributionDesignVariableTypeConverter(); + + // Call + var properties = converter.GetProperties(designVariable); + + // Assert + Assert.IsNotNull(properties); + Assert.AreEqual(5, properties.Count); + var distributionTypePropertyDescriptor = properties[0]; + Assert.AreEqual(typeof(string), distributionTypePropertyDescriptor.PropertyType); + Assert.IsTrue(distributionTypePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Type verdeling", distributionTypePropertyDescriptor.DisplayName); + Assert.AreEqual("De soort kansverdeling waarin deze parameter in gedefiniëerd wordt.", distributionTypePropertyDescriptor.Description); + Assert.AreEqual("DistributionType", distributionTypePropertyDescriptor.Name); + Assert.AreEqual("Verschoven lognormale verdeling", distributionTypePropertyDescriptor.GetValue(new object())); + + var meanPropertyDescriptor = properties[1]; + Assert.AreEqual(distribution.GetType().BaseType, meanPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), meanPropertyDescriptor.PropertyType); + Assert.IsFalse(meanPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03BC", meanPropertyDescriptor.DisplayName); + Assert.AreEqual("De gemiddelde waarde van de verschoven lognormale verdeling.", meanPropertyDescriptor.Description); + + var stdPropertyDescriptor = properties[2]; + Assert.AreEqual(distribution.GetType().BaseType, stdPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), stdPropertyDescriptor.PropertyType); + Assert.IsFalse(stdPropertyDescriptor.IsReadOnly); + Assert.AreEqual("\u03C3", stdPropertyDescriptor.DisplayName); + Assert.AreEqual("De standaardafwijking van de verschoven lognormale verdeling.", stdPropertyDescriptor.Description); + + var shiftPropertyDescriptor = properties[3]; + Assert.AreEqual(distribution.GetType(), shiftPropertyDescriptor.ComponentType); + Assert.AreEqual(typeof(double), shiftPropertyDescriptor.PropertyType); + Assert.IsFalse(shiftPropertyDescriptor.IsReadOnly); + Assert.AreEqual("Verschuiving", shiftPropertyDescriptor.DisplayName); + Assert.AreEqual("De verschuiving van de lognormale verdeling.", shiftPropertyDescriptor.Description); + + var designValuePropertyDescriptor = properties[4]; + Assert.AreEqual(typeof(double), designValuePropertyDescriptor.PropertyType); + Assert.IsTrue(designValuePropertyDescriptor.IsReadOnly); + Assert.AreEqual("Rekenwaarde", designValuePropertyDescriptor.DisplayName); + Assert.AreEqual("De representatieve waarde die gebruikt wordt door de berekening.", designValuePropertyDescriptor.Description); + Assert.AreEqual("DesignValue", designValuePropertyDescriptor.Name); + Assert.AreEqual(designVariable.GetDesignValue(), designValuePropertyDescriptor.GetValue(new object())); + } + + // TODO: Add integration test if parameter 'Saturated volumetric weight of the cover layer' can be found somewhere in the application. Probably should be a soil layer property (SoilLayer.BelowPhreaticLevel). + } +} \ No newline at end of file Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/ShiftedLognormalDistributionTypeConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5076e379f409c3b5ba41eb98256e3dd5d140571c refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TypeConverters/TextPropertyDescriptorDecoratorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/TestHelpers/PipingDataFactory.cs =================================================================== diff -u -r6692dc3480971fe1c017aef633382c40eb37056f -r5076e379f409c3b5ba41eb98256e3dd5d140571c --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/TestHelpers/PipingDataFactory.cs (.../PipingDataFactory.cs) (revision 6692dc3480971fe1c017aef633382c40eb37056f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/TestHelpers/PipingDataFactory.cs (.../PipingDataFactory.cs) (revision 5076e379f409c3b5ba41eb98256e3dd5d140571c) @@ -45,10 +45,7 @@ { Mean = 2.0 }, - SandParticlesVolumicWeight = - { - Mean = 1.0 - }, + SandParticlesVolumicWeight = 1.0, SeepageLength = { Mean = 1.0