Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r15f9709130561c93bb217e1c7b5ab942be97f958 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 15f9709130561c93bb217e1c7b5ab942be97f958) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -1011,6 +1011,15 @@ } /// + /// Looks up a localized string similar to {0} (Verwachtingswaarde = {1}, Standaardafwijking = {2}). + /// + public static string DesignVariable_0_Mean_is_1_StandardDeviation_is_2 { + get { + return ResourceManager.GetString("DesignVariable_0_Mean_is_1_StandardDeviation_is_2", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De representatieve waarde die gebruikt wordt door de berekening.. /// public static string DesignVariableProperties_DesignValue_Description { @@ -3422,6 +3431,15 @@ } /// + /// Looks up a localized string similar to {0} (Verwachtingswaarde = {1}, Variatiecoëfficiënt = {2}). + /// + public static string VariationCoefficientDesignVariable_0_Mean_is_1_CoefficientOfVariation_is_2 { + get { + return ResourceManager.GetString("VariationCoefficientDesignVariable_0_Mean_is_1_CoefficientOfVariation_is_2", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Als u kiest voor bijwerken, dan wordt het resultaat van deze berekening verwijderd. /// ///Weet u zeker dat u wilt doorgaan?. Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r15f9709130561c93bb217e1c7b5ab942be97f958 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 15f9709130561c93bb217e1c7b5ab942be97f958) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -1244,4 +1244,10 @@ Rekenwaarde + + {0} (Verwachtingswaarde = {1}, Standaardafwijking = {2}) + + + {0} (Verwachtingswaarde = {1}, Variatiecoëfficiënt = {2}) + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DesignVariableProperties.cs =================================================================== diff -u -r15f9709130561c93bb217e1c7b5ab942be97f958 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DesignVariableProperties.cs (.../DesignVariableProperties.cs) (revision 15f9709130561c93bb217e1c7b5ab942be97f958) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DesignVariableProperties.cs (.../DesignVariableProperties.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -67,8 +67,10 @@ public override string ToString() { - return $"{DesignValue} ({Resources.NormalDistribution_Mean_DisplayName} = {Mean}, " + - $"{Resources.NormalDistribution_StandardDeviation_DisplayName} = {StandardDeviation})"; + return string.Format(Resources.DesignVariable_0_Mean_is_1_StandardDeviation_is_2, + DesignValue, + Mean, + StandardDeviation); } /// Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs =================================================================== diff -u -r15f9709130561c93bb217e1c7b5ab942be97f958 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs (.../VariationCoefficientDesignVariableProperties.cs) (revision 15f9709130561c93bb217e1c7b5ab942be97f958) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs (.../VariationCoefficientDesignVariableProperties.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -65,8 +65,10 @@ public override string ToString() { - return $"{DesignValue} ({Resources.NormalDistribution_Mean_DisplayName} = {Mean}, " + - $"{Resources.Distribution_VariationCoefficient_DisplayName} = {CoefficientOfVariation})"; + return string.Format(Resources.VariationCoefficientDesignVariable_0_Mean_is_1_CoefficientOfVariation_is_2, + DesignValue, + Mean, + CoefficientOfVariation); } /// Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -r10fc7315f4478647b2708f74c3e596cdf0e5a98c -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 10fc7315f4478647b2708f74c3e596cdf0e5a98c) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -96,6 +96,7 @@ + UserControl Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSoilLayerDataRow.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSoilLayerDataRow.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFormattedSoilLayerDataRow.cs (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -0,0 +1,133 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using System.Drawing; +using Core.Common.Utils; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.MacroStabilityInwards.Primitives; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.MacroStabilityInwards.Forms.Views +{ + /// + /// This class defines a formatted version of an object. + /// + public class MacroStabilityInwardsFormattedSoilLayerDataRow + { + /// + /// Creates a new instance of . + /// + /// The to format. + /// Thrown when + /// is null. + public MacroStabilityInwardsFormattedSoilLayerDataRow(IMacroStabilityInwardsSoilLayerData layerData) + { + if (layerData == null) + { + throw new ArgumentNullException(nameof(layerData)); + } + + MaterialName = layerData.MaterialName; + Color = layerData.Color; + IsAquifer = layerData.IsAquifer; + AbovePhreaticLevel = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData)); + BelowPhreaticLevel = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData)); + ShearStrengthModel = layerData.ShearStrengthModel; + Cohesion = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData)); + FrictionAngle = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData)); + ShearStrengthRatio = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData)); + StrengthIncreaseExponent = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData)); + UsePop = layerData.UsePop; + Pop = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData)); + } + + /// + /// Gets a value indicating whether or not the is an aquifer. + /// + public bool IsAquifer { get; } + + /// + /// Gets the name of the material that was assigned to the . + /// + public string MaterialName { get; } + + /// + /// Gets the that was used to represent the . + /// + public Color Color { get; } + + /// + /// Gets the formatted design variable for . + /// + public string AbovePhreaticLevel { get; } + + /// + /// Gets the formatted design variable for . + /// + public string BelowPhreaticLevel { get; } + + /// + /// Gets the type. + /// + [TypeConverter(typeof(EnumTypeConverter))] + public MacroStabilityInwardsShearStrengthModel ShearStrengthModel { get; } + + /// + /// Gets the formatted design variable for . + /// + public string Cohesion { get; } + + /// + /// Gets the formatted design variable for . + /// + public string FrictionAngle { get; } + + /// + /// Gets the formatted design variable for . + /// + public string ShearStrengthRatio { get; } + + /// + /// Gets the formatted design variable for . + /// + public string StrengthIncreaseExponent { get; } + + /// + /// Gets a value indicating whether or not the is using POP. + /// + public bool UsePop { get; } + + /// + /// Gets the formatted design variable for . + /// + public string Pop { get; } + + private static string FormatVariationCoefficientDesignVariable(VariationCoefficientDesignVariable designVariable) + { + return string.Format(RingtoetsCommonFormsResources.VariationCoefficientDesignVariable_0_Mean_is_1_CoefficientOfVariation_is_2, + designVariable.GetDesignValue(), + designVariable.Distribution.Mean, + designVariable.Distribution.CoefficientOfVariation); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs =================================================================== diff -u -r6d8d3fd1acfeb7043071005e29977dc69792d2f9 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 6d8d3fd1acfeb7043071005e29977dc69792d2f9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -183,6 +183,7 @@ private void UpdateViewData() { UpdateChartData(); + UpdateTableData(); } private void UpdateChartData() Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSoilLayerDataTable.cs =================================================================== diff -u -r85b10b88eb31823c50ca052d34baacc6e006ad4c -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSoilLayerDataTable.cs (.../MacroStabilityInwardsSoilLayerDataTable.cs) (revision 85b10b88eb31823c50ca052d34baacc6e006ad4c) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsSoilLayerDataTable.cs (.../MacroStabilityInwardsSoilLayerDataTable.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -20,14 +20,11 @@ // All rights reserved. using System.Collections.Generic; -using System.Drawing; using System.Linq; using Core.Common.Controls.DataGrid; -using Ringtoets.Common.Data.Probabilistics; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Forms.Properties; using Ringtoets.MacroStabilityInwards.Primitives; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.MacroStabilityInwards.Forms.Views { @@ -52,131 +49,46 @@ /// The collection of layers to show. public void SetData(IEnumerable layers) { - SetDataSource(layers?.Select(l => new FormattedMacroStabilityInwardsSoilLayerDataRow(l)).ToArray()); + SetDataSource(layers?.Select(l => new MacroStabilityInwardsFormattedSoilLayerDataRow(l)).ToArray()); } private void AddColumns() { - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.MaterialName), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.MaterialName), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_MaterialName, true); - AddColorColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Color), + AddColorColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.Color), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Color); - AddCheckBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.IsAquifer), + AddCheckBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.IsAquifer), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_IsAquifer, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.AbovePhreaticLevel), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.AbovePhreaticLevel), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_AbovePhreaticLevel, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.BelowPhreaticLevel), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.BelowPhreaticLevel), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_BelowPhreaticLevel, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.ShearStrengthModel), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.ShearStrengthModel), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_ShearStrengthModel, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Cohesion), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.Cohesion), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Cohesion, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.FrictionAngle), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.FrictionAngle), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_FrictionAngle, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.ShearStrengthRatio), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.ShearStrengthRatio), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_ShearStrengthRatio, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.StrengthIncreaseExponent), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.StrengthIncreaseExponent), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_StrengthIncreaseExponent, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.UsePop), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.UsePop), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_UsePop, true); - AddTextBoxColumn(nameof(FormattedMacroStabilityInwardsSoilLayerDataRow.Pop), + AddTextBoxColumn(nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.Pop), Resources.MacroStabilityInwardsSoilLayerDataTable_ColumnHeader_Pop, true); } - - private static string FormatDesignVariable(VariationCoefficientDesignVariable distribution) - { - return $"{distribution.GetDesignValue()} ({RingtoetsCommonFormsResources.NormalDistribution_Mean_DisplayName} = {distribution.Distribution.Mean}, " + - $"{RingtoetsCommonFormsResources.NormalDistribution_StandardDeviation_DisplayName} = {distribution.Distribution.CoefficientOfVariation})"; - } - - private class FormattedMacroStabilityInwardsSoilLayerDataRow - { - public FormattedMacroStabilityInwardsSoilLayerDataRow(IMacroStabilityInwardsSoilLayerData layerData) - { - MaterialName = layerData.MaterialName; - Color = layerData.Color; - IsAquifer = layerData.IsAquifer; - AbovePhreaticLevel = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData)); - BelowPhreaticLevel = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData)); - ShearStrengthModel = layerData.ShearStrengthModel; - Cohesion = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData)); - FrictionAngle = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData)); - ShearStrengthRatio = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData)); - StrengthIncreaseExponent = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData)); - UsePop = layerData.UsePop; - Pop = FormatDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData)); - } - - /// - /// Gets a value indicating whether or not the is an aquifer. - /// - public bool IsAquifer { get; } - - /// - /// Gets the name of the material that was assigned to the . - /// - public string MaterialName { get; } - - /// - /// Gets the that was used to represent the . - /// - public Color Color { get; } - - /// - /// Gets the formatted design variable for . - /// - public string AbovePhreaticLevel { get; } - - /// - /// Gets the formatted design variable for . - /// - public string BelowPhreaticLevel { get; } - - /// - /// Gets the type. - /// - public MacroStabilityInwardsShearStrengthModel ShearStrengthModel { get; } - - /// - /// Gets the formatted design variable for . - /// - public string Cohesion { get; } - - /// - /// Gets the formatted design variable for . - /// - public string FrictionAngle { get; } - - /// - /// Gets the formatted design variable for . - /// - public string ShearStrengthRatio { get; } - - /// - /// Gets the formatted design variable for . - /// - public string StrengthIncreaseExponent { get; } - - /// - /// Gets a value indicating whether or not the is using POP. - /// - public bool UsePop { get; } - - /// - /// Gets the formatted design variable for . - /// - public string Pop { get; } - } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsShearStrengthModel.cs =================================================================== diff -u -r9fa257acbd8aeded7918b346a8e120fdc80f95b0 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsShearStrengthModel.cs (.../MacroStabilityInwardsShearStrengthModel.cs) (revision 9fa257acbd8aeded7918b346a8e120fdc80f95b0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/MacroStabilityInwardsShearStrengthModel.cs (.../MacroStabilityInwardsShearStrengthModel.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -19,8 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.ComponentModel; -using Core.Common.Utils; using Core.Common.Utils.Attributes; using Ringtoets.MacroStabilityInwards.Primitives.Properties; @@ -29,7 +27,6 @@ /// /// All shear strength model types. /// - [TypeConverter(typeof(EnumTypeConverter))] public enum MacroStabilityInwardsShearStrengthModel { [ResourcesDisplayName(typeof(Resources), nameof(Resources.MacroStabilityInwardsShearStrengthModel_SuCalculated_DisplayName))] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -rd0dfbe43e89d97fb516d6c8a5cff1c35237ce715 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision d0dfbe43e89d97fb516d6c8a5cff1c35237ce715) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -104,6 +104,7 @@ + @@ -113,7 +114,7 @@ - + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFormattedSoilLayerDataRowTest.cs (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -0,0 +1,118 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using Core.Common.Utils; +using NUnit.Framework; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Forms.Views; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.Views +{ + [TestFixture] + public class MacroStabilityInwardsFormattedSoilLayerDataRowTest + { + [Test] + public void Constructor_SoilLayerDataNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsFormattedSoilLayerDataRow(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_WithSoilLayerData_ExpectedValues() + { + // Setup + var soilLayerData = new MacroStabilityInwardsSoilLayerData + { + MaterialName = "Sand", + Color = Color.Black, + IsAquifer = true, + AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 1.0, + Mean = (RoundedDouble) 1.0 + }, + BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 2.0, + Mean = (RoundedDouble) 2.0 + }, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi, + ShearStrengthRatio = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 3.0, + Mean = (RoundedDouble) 3.0 + }, + Cohesion = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 4.0, + Mean = (RoundedDouble) 4.0 + }, + FrictionAngle = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 5.0, + Mean = (RoundedDouble) 5.0 + }, + StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 6.0, + Mean = (RoundedDouble) 6.0 + }, + UsePop = true, + Pop = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = (RoundedDouble) 7.0, + Mean = (RoundedDouble) 7.0 + } + }; + + // Call + var formattedSoilLayerDataRow = new MacroStabilityInwardsFormattedSoilLayerDataRow(soilLayerData); + + // Assert + + TestHelper.AssertTypeConverter( + nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.ShearStrengthModel)); + + Assert.AreEqual(soilLayerData.MaterialName, formattedSoilLayerDataRow.MaterialName); + Assert.AreEqual(soilLayerData.Color, formattedSoilLayerDataRow.Color); + Assert.AreEqual(soilLayerData.IsAquifer, formattedSoilLayerDataRow.IsAquifer); + Assert.AreEqual("0,71 (Verwachtingswaarde = 1,00, Variatiecoëfficiënt = 1,00)", formattedSoilLayerDataRow.AbovePhreaticLevel); + Assert.AreEqual("0,89 (Verwachtingswaarde = 2,00, Variatiecoëfficiënt = 2,00)", formattedSoilLayerDataRow.BelowPhreaticLevel); + Assert.AreEqual(soilLayerData.ShearStrengthModel, formattedSoilLayerDataRow.ShearStrengthModel); + Assert.AreEqual("0,08 (Verwachtingswaarde = 3,00, Variatiecoëfficiënt = 3,00)", formattedSoilLayerDataRow.ShearStrengthRatio); + Assert.AreEqual("0,06 (Verwachtingswaarde = 4,00, Variatiecoëfficiënt = 4,00)", formattedSoilLayerDataRow.Cohesion); + Assert.AreEqual("0,05 (Verwachtingswaarde = 5,00, Variatiecoëfficiënt = 5,00)", formattedSoilLayerDataRow.FrictionAngle); + Assert.AreEqual("0,04 (Verwachtingswaarde = 6,00, Variatiecoëfficiënt = 6,00)", formattedSoilLayerDataRow.StrengthIncreaseExponent); + Assert.AreEqual(soilLayerData.UsePop, formattedSoilLayerDataRow.UsePop); + Assert.AreEqual("0,04 (Verwachtingswaarde = 7,00, Variatiecoëfficiënt = 7,00)", formattedSoilLayerDataRow.Pop); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs =================================================================== diff -u -r6d8d3fd1acfeb7043071005e29977dc69792d2f9 -r3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs (.../MacroStabilityInwardsInputViewTest.cs) (revision 6d8d3fd1acfeb7043071005e29977dc69792d2f9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsInputViewTest.cs (.../MacroStabilityInwardsInputViewTest.cs) (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -162,6 +162,47 @@ } [Test] + public void Data_SetToNull_TableDataCleared() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile( + 0.1, new MacroStabilityInwardsSoilProfile1D( + "profile", + -1, + new[] + { + new MacroStabilityInwardsSoilLayer1D(3.0), + new MacroStabilityInwardsSoilLayer1D(2.0), + new MacroStabilityInwardsSoilLayer1D(0) + })) + } + }; + + using (var view = new MacroStabilityInwardsInputView + { + Data = calculation + }) + { + var tableControl = view.Controls.Find("soilLayerDataTable", true).First() as MacroStabilityInwardsSoilLayerDataTable; + + // Precondition + Assert.NotNull(tableControl); + Assert.AreEqual(3, tableControl.Rows.Count); + + // Call + view.Data = null; + + // Assert + Assert.IsNull(view.Data); + CollectionAssert.IsEmpty(tableControl.Rows); + } + } + + [Test] public void Data_WithSurfaceLineAndSoilProfile1D_DataUpdatedToCollectionOfFilledChartData() { // Setup @@ -602,6 +643,59 @@ } [Test] + public void GivenViewWithStochasticSoilProfile_WhenStochasticSoilProfileUpdated_ThenDataTableUpdated() + { + // Given + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + using (var view = new MacroStabilityInwardsInputView()) + { + MacroStabilityInwardsSoilLayerDataTable soilLayerDataTable = GetSoilLayerTable(view); + + var calculation = new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.5, + new MacroStabilityInwardsSoilProfile1D( + "profile 1D", + -1, + new[] + { + new MacroStabilityInwardsSoilLayer1D(1) + })), + SurfaceLine = GetSurfaceLineWithGeometry() + } + }; + + view.Data = calculation; + + // Precondition + Assert.AreEqual(1, soilLayerDataTable.Rows.Count); + + // When + calculation.InputParameters.Attach(observer); + calculation.InputParameters.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.5, + new MacroStabilityInwardsSoilProfile1D( + "new profile 1D", + -1, + new[] + { + new MacroStabilityInwardsSoilLayer1D(3), + new MacroStabilityInwardsSoilLayer1D(4) + })); + calculation.InputParameters.NotifyObservers(); + + // Then + Assert.AreEqual(2, soilLayerDataTable.Rows.Count); + mocks.VerifyAll(); + } + } + + [Test] public void GivenViewWithGridPoints_WhenGridDeterminationTypeSetToAutomatic_ThenNoGridPoints() { // Given Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSoilLayerDataTableTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSoilLayerDataTableTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSoilLayerDataTableTest.cs (revision 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298) @@ -0,0 +1,280 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Windows.Forms; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Forms.Views; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.Views +{ + [TestFixture] + public class MacroStabilityInwardsSoilLayerDataTableTest + { + private const int nameColumnIndex = 0; + private const int colorColumnIndex = 1; + private const int isAquiferColumnIndex = 2; + private const int abovePhreaticLevelColumnIndex = 3; + private const int belowPhreaticLevelColumnIndex = 4; + private const int shearStrengthModelColumnIndex = 5; + private const int cohesionColumnIndex = 6; + private const int frictionAngleColumnIndex = 7; + private const int shrearStrengthRatioColumnIndex = 8; + private const int strengthIncreaseExponentColumnIndex = 9; + private const int usePopColumnIndex = 10; + private const int popColumnIndex = 11; + + [Test] + public void Constructor_InitializesWithColumns() + { + // Call + using (var table = new MacroStabilityInwardsSoilLayerDataTable()) + { + // Assert + DataGridViewColumn nameColumn = table.GetColumnFromIndex(nameColumnIndex); + Assert.AreEqual("Naam", nameColumn.HeaderText); + DataGridViewColumn colorColumn = table.GetColumnFromIndex(colorColumnIndex); + Assert.AreEqual("Kleur", colorColumn.HeaderText); + DataGridViewColumn abovePhreaticLevelColumn = table.GetColumnFromIndex(abovePhreaticLevelColumnIndex); + Assert.AreEqual("Onverzadigd gewicht [kN/m³]", abovePhreaticLevelColumn.HeaderText); + DataGridViewColumn belowPhreaticLevelColumn = table.GetColumnFromIndex(belowPhreaticLevelColumnIndex); + Assert.AreEqual("Verzadigd gewicht [kN/m³]", belowPhreaticLevelColumn.HeaderText); + DataGridViewColumn shearStrengthModelColumn = table.GetColumnFromIndex(shearStrengthModelColumnIndex); + Assert.AreEqual("Schuifsterkte model", shearStrengthModelColumn.HeaderText); + DataGridViewColumn cohesionColumn = table.GetColumnFromIndex(cohesionColumnIndex); + Assert.AreEqual("Cohesie [kN/m³]", cohesionColumn.HeaderText); + DataGridViewColumn frictionAngleColumn = table.GetColumnFromIndex(frictionAngleColumnIndex); + Assert.AreEqual("Wrijvingshoek [°]", frictionAngleColumn.HeaderText); + DataGridViewColumn shrearStrengthRatioColumn = table.GetColumnFromIndex(shrearStrengthRatioColumnIndex); + Assert.AreEqual("Schuifsterkte ratio S [-]", shrearStrengthRatioColumn.HeaderText); + DataGridViewColumn strengthIncreaseExponentColumn = table.GetColumnFromIndex(strengthIncreaseExponentColumnIndex); + Assert.AreEqual("Sterkte toename exp (m) [-]", strengthIncreaseExponentColumn.HeaderText); + DataGridViewColumn usePopColumn = table.GetColumnFromIndex(usePopColumnIndex); + Assert.AreEqual("Gebruik POP", usePopColumn.HeaderText); + DataGridViewColumn popColumn = table.GetColumnFromIndex(popColumnIndex); + Assert.AreEqual("POP [kN/m³]", popColumn.HeaderText); + + Assert.Throws(() => table.GetColumnFromIndex(popColumnIndex + 1)); + + CollectionAssert.IsEmpty(table.Rows); + } + } + + [Test] + public void SetData_NoDataAlreadySet_SetNewData() + { + // Setup + using (var table = new MacroStabilityInwardsSoilLayerDataTable()) + { + var layers = new[] + { + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData() + }; + + // Call + table.SetData(layers); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + } + } + + [Test] + public void SetData_SetNullDataAfterDataAlreadySet_ClearsData() + { + // Setup + using (var table = new MacroStabilityInwardsSoilLayerDataTable()) + { + var layers = new[] + { + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData() + }; + table.SetData(layers); + + // Call + table.SetData(null); + + // Assert + Assert.AreEqual(0, table.Rows.Count); + } + } + + [Test] + public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData() + { + // Setup + using (var table = new MacroStabilityInwardsSoilLayerDataTable()) + { + var layers = new[] + { + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData(), + new MacroStabilityInwardsSoilLayerData() + }; + table.SetData(new[] + { + new MacroStabilityInwardsSoilLayerData() + }); + + // Call + table.SetData(layers); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + } + } + + [Test] + public void SetData_WithData_ExpectedValuesInTable() + { + // Setup + using (var table = new MacroStabilityInwardsSoilLayerDataTable()) + { + var layers = new[] + { + CreateMacroStabilityInwardsSoilLayerData(), + CreateMacroStabilityInwardsSoilLayerData(), + CreateMacroStabilityInwardsSoilLayerData() + }; + table.SetData(new[] + { + new MacroStabilityInwardsSoilLayerData() + }); + + // Call + table.SetData(layers); + + // Assert + Assert.AreEqual(3, table.Rows.Count); + for (var i = 0; i < table.Rows.Count; i++) + { + MacroStabilityInwardsSoilLayerData soilLayerData = layers[i]; + DataGridViewCellCollection rowCells = table.Rows[i].Cells; + AssertColumnValueEqual(soilLayerData.MaterialName, + rowCells[nameColumnIndex].Value); + AssertColumnValueEqual(soilLayerData.Color, + rowCells[colorColumnIndex].Value); + AssertColumnValueEqual(soilLayerData.IsAquifer, + rowCells[isAquiferColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(soilLayerData), + rowCells[abovePhreaticLevelColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(soilLayerData), + rowCells[belowPhreaticLevelColumnIndex].Value); + AssertColumnValueEqual(soilLayerData.ShearStrengthModel, + rowCells[shearStrengthModelColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(soilLayerData), + rowCells[cohesionColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(soilLayerData), + rowCells[frictionAngleColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(soilLayerData), + rowCells[shrearStrengthRatioColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(soilLayerData), + rowCells[strengthIncreaseExponentColumnIndex].Value); + AssertColumnValueEqual(soilLayerData.UsePop, + rowCells[usePopColumnIndex].Value); + AssertColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(soilLayerData), + rowCells[popColumnIndex].Value); + } + } + } + + private static void AssertColumnValueEqual(object expectedValue, object actualValue) + { + if (expectedValue is RoundedDouble) + { + Assert.IsInstanceOf(actualValue); + var expectedRoundedDouble = (RoundedDouble) expectedValue; + Assert.AreEqual(expectedRoundedDouble, (RoundedDouble) actualValue, expectedRoundedDouble.GetAccuracy()); + } + else if (expectedValue is VariationCoefficientDesignVariable) + { + var expectedDesignVariable = (VariationCoefficientDesignVariable) expectedValue; + string expectedFormattedDesignVariable = $"{expectedDesignVariable.GetDesignValue()} (Verwachtingswaarde = {expectedDesignVariable.Distribution.Mean}, " + + $"Variatiecoëfficiënt = {expectedDesignVariable.Distribution.CoefficientOfVariation})"; + Assert.AreEqual(expectedFormattedDesignVariable, actualValue); + } + else + { + Assert.AreEqual(expectedValue, actualValue); + } + } + + private static MacroStabilityInwardsSoilLayerData CreateMacroStabilityInwardsSoilLayerData() + { + var random = new Random(21); + + return new MacroStabilityInwardsSoilLayerData + { + MaterialName = $"{random.NextDouble()}", + Color = Color.FromKnownColor(random.NextEnumValue()), + IsAquifer = random.NextBoolean(), + AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + ShearStrengthModel = random.NextEnumValue(), + ShearStrengthRatio = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + Cohesion = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + FrictionAngle = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + }, + UsePop = random.NextBoolean(), + Pop = new VariationCoefficientLogNormalDistribution + { + CoefficientOfVariation = random.NextRoundedDouble(), + Mean = random.NextRoundedDouble() + } + }; + } + } +} \ No newline at end of file Fisheye: Tag 3a85bb13c6b7c5c6c90cd0b837e1e09607f29298 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsSoilLayerTableTest.cs'. Fisheye: No comparison available. Pass `N' to diff?