Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -53,7 +53,7 @@ public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState assessmentLayerOneResult, - [Values(3.2, 4.5)] double assessmentLayerThreeResult) + [Values(0.2, 0.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -52,7 +52,7 @@ public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState assessmentLayerOneResult, - [Values(3.2, 4.5)] double assessmentLayerThreeResult) + [Values(0.2, 0.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -53,7 +53,7 @@ public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState assessmentLayerOneResult, - [Values(3.2, 4.5)] double assessmentLayerThreeResult) + [Values(0.2, 0.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -rdd37de7257c4586b66f6e3d49295cd9b295ca5ec -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision dd37de7257c4586b66f6e3d49295cd9b295ca5ec) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -40,7 +40,7 @@ // Setup var random = new Random(); var assessmentLayerOneResult = random.NextEnumValue(); - const double assessmentLayerThreeResult = 3.2; + const double assessmentLayerThreeResult = 0.2; var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismSectionResultCreateExtensionsTest.cs (.../PipingFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingFailureMechanismSectionResultCreateExtensionsTest.cs (.../PipingFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -38,7 +38,7 @@ public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState assessmentLayerOneResult, - [Values(3.2, 4.5)] double assessmentLayerThreeResult) + [Values(0.2, 0.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityPointStructures/StabilityPointStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityPointStructures/StabilityPointStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityPointStructures/StabilityPointStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -53,7 +53,7 @@ public void Create_VariousResults_ReturnsEntity( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState assessmentLayerOneResult, - [Values(3.2, 4.5)] double assessmentLayerThreeResult) + [Values(0.2, 0.5)] double assessmentLayerThreeResult) { // Setup var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -70,7 +70,7 @@ AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState layerOne, [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed, AssessmentLayerTwoAResult.Successful)] AssessmentLayerTwoAResult layerTwoA, - [Values(1.1, 2.2, null)] double? layerThree) + [Values(0.1, 0.2, null)] double? layerThree) { // Setup var collector = new ReadConversionCollector(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -66,7 +66,7 @@ public void Read_ParameterValues_SectionResultWithParameterValues( [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState layerOne, - [Values(1.1, 2.2, null)] double? layerThree) + [Values(0.1, 0.2, null)] double? layerThree) { // Setup var collector = new ReadConversionCollector(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresSectionResultEntityReadExtensionsTest.cs (.../HeightStructuresSectionResultEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresSectionResultEntityReadExtensionsTest.cs (.../HeightStructuresSectionResultEntityReadExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -70,7 +70,7 @@ AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState layerOne, [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed, AssessmentLayerTwoAResult.Successful)] AssessmentLayerTwoAResult layerTwoA, - [Values(1.1, 2.2, null)] double? layerThree) + [Values(0.1, 0.2, null)] double? layerThree) { // Setup var collector = new ReadConversionCollector(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs (.../PipingSectionResultEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSectionResultEntityReadExtensionsTest.cs (.../PipingSectionResultEntityReadExtensionsTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -54,7 +54,7 @@ AssessmentLayerOneState.Sufficient)] AssessmentLayerOneState layerOne, [Values(AssessmentLayerTwoAResult.NotCalculated, AssessmentLayerTwoAResult.Failed, AssessmentLayerTwoAResult.Successful)] AssessmentLayerTwoAResult layerTwoA, - [Values(1.1, 2.2, null)] double? layerThree) + [Values(0.1, 0.2, null)] double? layerThree) { // Setup var collector = new ReadConversionCollector(); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -22,6 +22,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -589,6 +590,75 @@ } } + [Test] + [TestCase("test", assessmentLayerThreeIndex)] + [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerThreeIndex)] + public void FailureMechanismResultView_EditValueInvalid_ShowsErrorTooltip(string newValue, int cellIndex) + { + // Setup + using (CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[cellIndex].Value = newValue; + + // Assert + Assert.AreEqual("De tekst moet een getal zijn.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + [TestCase("5")] + [TestCase("-10")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] + [TestCase("1")] + [TestCase("0")] + [TestCase("0.5")] + [TestCase("1e-6")] + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) + { + // Setup + using (ClosingStructuresFailureMechanismResultView view = CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.IsEmpty(dataGridView.Rows[0].ErrorText); + + var dataObject = view.Data as List; + Assert.IsNotNull(dataObject); + ClosingStructuresFailureMechanismSectionResult row = dataObject.First(); + + const string propertyName = "AssessmentLayerThree"; + object propertyValue = row.GetType().GetProperty(propertyName).GetValue(row, null); + + Assert.AreEqual((RoundedDouble) double.Parse(newValue), propertyValue); + } + } + private static IEnumerable AssessmentLayerOneStateIsSufficientVariousSections() { FailureMechanismSection section = CreateSimpleFailureMechanismSection(); Index: Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/FailureMechanismSectionResult.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/FailureMechanismSectionResult.cs (.../FailureMechanismSectionResult.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/src/Ringtoets.Common.Data/FailureMechanism/FailureMechanismSectionResult.cs (.../FailureMechanismSectionResult.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -30,6 +30,8 @@ /// public abstract class FailureMechanismSectionResult : Observable { + private RoundedDouble assessmentLayerThreeValue; + /// /// Creates a new instance of . /// @@ -54,11 +56,35 @@ /// /// Gets or sets the value of the tailored assessment of safety. /// - public RoundedDouble AssessmentLayerThree { get; set; } + /// Thrown when + /// is outside of the valid ranges. + public RoundedDouble AssessmentLayerThree + { + get + { + return assessmentLayerThreeValue; + } + set + { + assessmentLayerThreeValue = ValidateAssessmentLayerThree(value); + } + } /// /// Gets the encapsulated . /// public FailureMechanismSection Section { get; private set; } + + /// + /// Validates the value of the tailored assessment of safety + /// + /// The value to validate. + /// The validated value. + /// Thrown when + /// is outside of the valid ranges. + protected virtual RoundedDouble ValidateAssessmentLayerThree(RoundedDouble value) + { + return value; + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs =================================================================== diff -u -r5e1c552bd6b82241abc970ef95c55b2b1c9169ec -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs (.../StructuresFailureMechanismSectionResult.cs) (revision 5e1c552bd6b82241abc970ef95c55b2b1c9169ec) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresFailureMechanismSectionResult.cs (.../StructuresFailureMechanismSectionResult.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using Core.Common.Base.Data; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; namespace Ringtoets.Common.Data.Structures { @@ -44,5 +46,11 @@ /// to be representative for the whole section. /// public StructuresCalculation Calculation { get; set; } + + protected override RoundedDouble ValidateAssessmentLayerThree(RoundedDouble value) + { + ProbabilityHelper.ValidateProbability(value, null, true); + return value; + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismSectionResultTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismSectionResultTest.cs (.../FailureMechanismSectionResultTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismSectionResultTest.cs (.../FailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -76,11 +76,14 @@ } [Test] - public void AssessmentLayerThree_SetNewValue_ReturnsNewValue() + [TestCase(double.NaN)] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] + [TestCase(5)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetNewValue_ReturnsNewValue(double newValue) { // Setup - var random = new Random(21); - double newValue = random.NextDouble(); FailureMechanismSection section = CreateSection(); var failureMechanismSectionResult = new TestFailureMechanismSectionResult(section); Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresFailureMechanismSectionResultTest.cs =================================================================== diff -u -r89bea52ae1b4639721b93bdd4a537f36ec6d6b9c -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresFailureMechanismSectionResultTest.cs (.../StructuresFailureMechanismSectionResultTest.cs) (revision 89bea52ae1b4639721b93bdd4a537f36ec6d6b9c) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresFailureMechanismSectionResultTest.cs (.../StructuresFailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -19,10 +19,14 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.Common.Data.Test.Structures { @@ -41,6 +45,7 @@ // Assert Assert.IsInstanceOf>(sectionResult); Assert.IsNull(sectionResult.Calculation); + Assert.IsNaN(sectionResult.AssessmentLayerThree); Assert.AreSame(section, sectionResult.Section); } @@ -61,6 +66,44 @@ Assert.AreSame(calculation, result.Calculation); } + [Test] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void AssessmentLayerThree_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidValue) + { + // Setup + var sectionResult = new TestStructuresFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) invalidValue; + + // Assert + const string expectedMessage = "Kans moet in het bereik [0.0, 1.0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, + expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetValidValue_SetsValue(double validValue) + { + // Setup + var sectionResult = new TestStructuresFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) validValue; + + // Assert + Assert.DoesNotThrow(call); + Assert.AreEqual(validValue, sectionResult.AssessmentLayerThree, sectionResult.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("Section", new[] Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r711f6909f672eff30cea67489cb7372f01e7aff9 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResult.cs) (revision 711f6909f672eff30cea67489cb7372f01e7aff9) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsFailureMechanismSectionResult.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResult.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using Core.Common.Base.Data; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; namespace Ringtoets.GrassCoverErosionInwards.Data { @@ -57,5 +59,11 @@ /// to be representative for the whole section. /// public GrassCoverErosionInwardsCalculation Calculation { get; set; } + + protected override RoundedDouble ValidateAssessmentLayerThree(RoundedDouble value) + { + ProbabilityHelper.ValidateProbability(value, null, true); + return value; + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismSectionResultTest.cs =================================================================== diff -u -r3c5eb8dc63626571ddee036cac675707bd0b0ff0 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismSectionResultTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultTest.cs) (revision 3c5eb8dc63626571ddee036cac675707bd0b0ff0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismSectionResultTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -19,9 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; namespace Ringtoets.GrassCoverErosionInwards.Data.Test @@ -41,6 +45,7 @@ // Assert Assert.IsInstanceOf(result); Assert.AreSame(section, result.Section); + Assert.IsNaN(result.AssessmentLayerThree); Assert.IsNaN(result.AssessmentLayerTwoA); } @@ -126,6 +131,43 @@ Assert.AreEqual(probability, twoAValue); } + [Test] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void AssessmentLayerThree_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidValue) + { + // Setup + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble)invalidValue; + + // Assert + const string expectedMessage = "Kans moet in het bereik [0.0, 1.0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, + expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetValidValue_SetsValue(double validValue) + { + // Setup + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble)validValue; + + // Assert + Assert.DoesNotThrow(call); + Assert.AreEqual(validValue, sectionResult.AssessmentLayerThree, sectionResult.AssessmentLayerThree.GetAccuracy()); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("Section", new[] Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r3c5eb8dc63626571ddee036cac675707bd0b0ff0 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision 3c5eb8dc63626571ddee036cac675707bd0b0ff0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -238,11 +238,31 @@ } [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (ShowFullyConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] [TestCase("1")] + [TestCase("0")] + [TestCase("0.5")] [TestCase("1e-6")] - [TestCase("1e+6")] - [TestCase("14.3")] - public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(string newValue) + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) { // Setup using (GrassCoverErosionInwardsFailureMechanismResultView view = ShowFullyConfiguredFailureMechanismResultsView()) Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -243,11 +243,33 @@ } [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + [TestCase("5")] + [TestCase("-10")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (ShowFullyConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] [TestCase("1")] + [TestCase("0")] + [TestCase("0.5")] [TestCase("1e-6")] - [TestCase("1e+6")] - [TestCase("14.3")] - public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(string newValue) + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) { // Setup using (HeightStructuresFailureMechanismResultView view = ShowFullyConfiguredFailureMechanismResultsView()) Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResult.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResult.cs (.../MacroStabilityInwardsFailureMechanismSectionResult.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsFailureMechanismSectionResult.cs (.../MacroStabilityInwardsFailureMechanismSectionResult.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using Core.Common.Base.Data; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; namespace Ringtoets.MacroStabilityInwards.Data { @@ -36,5 +38,11 @@ /// The to get the result from. /// Thrown when is null. public MacroStabilityInwardsFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + + protected override RoundedDouble ValidateAssessmentLayerThree(RoundedDouble value) + { + ProbabilityHelper.ValidateProbability(value, null, true); + return value; + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultTest.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultTest.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsFailureMechanismSectionResultTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -19,9 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.MacroStabilityInwards.Data.Test { @@ -32,18 +36,61 @@ public void Constructor_WithParameters_ExpectedValues() { // Setup - var section = new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - }); + FailureMechanismSection section = CreateSection(); // Call var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(section); // Assert Assert.IsInstanceOf(sectionResult); Assert.AreSame(section, sectionResult.Section); + Assert.IsNaN(sectionResult.AssessmentLayerThree); Assert.IsNaN(sectionResult.GetAssessmentLayerTwoA(new MacroStabilityInwardsCalculationScenario[0])); } + + [Test] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void AssessmentLayerThree_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidValue) + { + // Setup + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) invalidValue; + + // Assert + const string expectedMessage = "Kans moet in het bereik [0.0, 1.0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, + expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetValidValue_SetsValue(double validValue) + { + // Setup + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) validValue; + + // Assert + Assert.DoesNotThrow(call); + Assert.AreEqual(validValue, sectionResult.AssessmentLayerThree, sectionResult.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + }); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -238,11 +238,29 @@ } [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (ShowFullyConfiguredFailureMechanismResultsView(new MacroStabilityInwardsFailureMechanism())) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] [TestCase("1")] [TestCase("1e-6")] - [TestCase("1e+6")] - [TestCase("14.3")] - public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(string newValue) + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) { // Setup using (MacroStabilityInwardsFailureMechanismResultView view = ShowFullyConfiguredFailureMechanismResultsView(new MacroStabilityInwardsFailureMechanism())) Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs (.../PipingFailureMechanismSectionResult.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingFailureMechanismSectionResult.cs (.../PipingFailureMechanismSectionResult.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using Core.Common.Base.Data; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probability; namespace Ringtoets.Piping.Data { @@ -36,5 +38,11 @@ /// The to get the result from. /// Thrown when is null. public PipingFailureMechanismSectionResult(FailureMechanismSection section) : base(section) {} + + protected override RoundedDouble ValidateAssessmentLayerThree(RoundedDouble value) + { + ProbabilityHelper.ValidateProbability(value, null, true); + return value; + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs (.../PipingFailureMechanismSectionResultTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingFailureMechanismSectionResultTest.cs (.../PipingFailureMechanismSectionResultTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -19,9 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.Piping.Data.Test { @@ -32,18 +36,61 @@ public void Constructor_WithParameters_ExpectedValues() { // Setup - var section = new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - }); + FailureMechanismSection section = CreateSection(); // Call var sectionResult = new PipingFailureMechanismSectionResult(section); // Assert Assert.IsInstanceOf(sectionResult); Assert.AreSame(section, sectionResult.Section); + Assert.IsNaN(sectionResult.AssessmentLayerThree); Assert.IsNaN(sectionResult.GetAssessmentLayerTwoA(new PipingCalculationScenario[0])); } + + [Test] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + [TestCase(1.1)] + [TestCase(-0.1)] + public void AssessmentLayerThree_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidValue) + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) invalidValue; + + // Assert + const string expectedMessage = "Kans moet in het bereik [0.0, 1.0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, + expectedMessage); + } + + [Test] + [TestCase(double.NaN)] + [TestCase(0)] + [TestCase(1)] + [TestCase(0.5)] + public void AssessmentLayerThree_SetValidValue_SetsValue(double validValue) + { + // Setup + var sectionResult = new PipingFailureMechanismSectionResult(CreateSection()); + + // Call + TestDelegate call = () => sectionResult.AssessmentLayerThree = (RoundedDouble) validValue; + + // Assert + Assert.DoesNotThrow(call); + Assert.AreEqual(validValue, sectionResult.AssessmentLayerThree, sectionResult.AssessmentLayerThree.GetAccuracy()); + } + + private static FailureMechanismSection CreateSection() + { + return new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + }); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -238,11 +238,31 @@ } [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (ShowFullyConfiguredFailureMechanismResultsView(new PipingFailureMechanism())) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] [TestCase("1")] + [TestCase("0")] + [TestCase("0.5")] [TestCase("1e-6")] - [TestCase("1e+6")] - [TestCase("14.3")] - public void FailureMechanismResultView_EditValueValid_DoNotShowErrorToolTipAndEditValue(string newValue) + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) { // Setup using (PipingFailureMechanismResultView view = ShowFullyConfiguredFailureMechanismResultsView(new PipingFailureMechanism())) Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -rb6e0f8d41d92ed18c902138dd49cce6e703ee883 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision b6e0f8d41d92ed18c902138dd49cce6e703ee883) @@ -22,6 +22,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -587,6 +588,76 @@ } } + + [Test] + [TestCase("test", assessmentLayerThreeIndex)] + [TestCase(";/[].,~!@#$%^&*()_-+={}|?", assessmentLayerThreeIndex)] + public void FailureMechanismResultView_EditValueInvalid_ShowsErrorTooltip(string newValue, int cellIndex) + { + // Setup + using (CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[cellIndex].Value = newValue; + + // Assert + Assert.AreEqual("De tekst moet een getal zijn.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] + [SetCulture("nl-NL")] + [TestCase("1.01")] + [TestCase("-0.01")] + [TestCase("5")] + [TestCase("-10")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeInvalid_ShowErrorToolTip(string newValue) + { + // Setup + using (CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.AreEqual("Kans moet in het bereik [0,0, 1,0] liggen.", dataGridView.Rows[0].ErrorText); + } + } + + [Test] + [TestCase("1")] + [TestCase("0")] + [TestCase("0.5")] + [TestCase("1e-6")] + [TestCase("NaN")] + public void FailureMechanismResultView_EditValueAssessmentLayerThreeValid_DoNotShowErrorToolTipAndEditValue(string newValue) + { + // Setup + using (StabilityPointStructuresFailureMechanismResultView view = CreateConfiguredFailureMechanismResultsView()) + { + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + + // Call + dataGridView.Rows[0].Cells[assessmentLayerThreeIndex].Value = newValue; + + // Assert + Assert.IsEmpty(dataGridView.Rows[0].ErrorText); + + var dataObject = view.Data as List; + Assert.IsNotNull(dataObject); + StabilityPointStructuresFailureMechanismSectionResult row = dataObject.First(); + + const string propertyName = "AssessmentLayerThree"; + object propertyValue = row.GetType().GetProperty(propertyName).GetValue(row, null); + + Assert.AreEqual((RoundedDouble)double.Parse(newValue), propertyValue); + } + } + private static IEnumerable AssessmentLayerOneStateIsSufficientVariousSections() { FailureMechanismSection section = CreateSimpleFailureMechanismSection();