Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -rf31183a0e18731b0b2ef9487c7f7a09713c4c5ef -r3dba5efb1341e8aaba0de9848669b1c7e45cdfda --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision f31183a0e18731b0b2ef9487c7f7a09713c4c5ef) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 3dba5efb1341e8aaba0de9848669b1c7e45cdfda) @@ -21,12 +21,14 @@ using System; using System.ComponentModel; +using System.Globalization; using System.Linq; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.ClosingStructures.Data; @@ -267,6 +269,279 @@ } [Test] + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void SetProbabilityOpenStructureBeforeFlooding_InvalidValues_ThrowsArgumentException(double newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.ProbabilityOpenStructureBeforeFlooding = newValue.ToString(CultureInfo.InvariantCulture); + + // Assert + var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase("no double value")] + [TestCase("")] + public void SetProbabilityOpenStructureBeforeFlooding_ValuesUnableToParse_ThrowsArgumentException(string newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.ProbabilityOpenStructureBeforeFlooding = newValue; + + // Assert + var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + public void SetProbabilityOpenStructureBeforeFlooding_NullValue_ThrowsArgumentNullException() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.ProbabilityOpenStructureBeforeFlooding = null; + + // Assert + var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void SetFailureProbabilityOpenStructure_InvalidValues_ThrowsArgumentException(double newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityOpenStructure = newValue.ToString(CultureInfo.InvariantCulture); + + // Assert + var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase("no double value")] + [TestCase("")] + public void SetFailureProbabilityOpenStructure_ValuesUnableToParse_ThrowsArgumentException(string newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityOpenStructure = newValue; + + // Assert + var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + public void SetFailureProbabilityOpenStructure_NullValue_ThrowsArgumentNullException() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityOpenStructure = null; + + // Assert + var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void SetFailureProbabilityReparation_InvalidValues_ThrowsArgumentException(double newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityReparation = newValue.ToString(CultureInfo.InvariantCulture); + + // Assert + var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase("no double value")] + [TestCase("")] + public void SetFailureProbabilityReparation_ValuesUnableToParse_ThrowsArgumentException(string newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityReparation = newValue; + + // Assert + var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + public void SetFailureProbabilityReparation_NullValue_ThrowsArgumentNullException() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculation = new StructuresCalculation(); + var input = calculation.InputParameters; + var inputContext = new ClosingStructuresInputContext(input, + calculation, + failureMechanism, + assessmentSectionStub); + var properties = new ClosingStructuresInputContextProperties + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityReparation = null; + + // Assert + var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] public void PropertyAttributes_ReturnExpectedValues() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -rf05ca3345e173bcdd462ca8ea4b6f12b2de86e2c -r3dba5efb1341e8aaba0de9848669b1c7e45cdfda --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision f05ca3345e173bcdd462ca8ea4b6f12b2de86e2c) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 3dba5efb1341e8aaba0de9848669b1c7e45cdfda) @@ -240,9 +240,7 @@ } [Test] - [TestCase(double.MinValue)] - [TestCase(double.MaxValue)] - public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) + public void SetStructure_NullValue_AfterSettingStructureCalled() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -259,18 +257,18 @@ Data = inputContext }; + // Precondition + Assert.IsFalse(properties.AfterSettingStructureCalled); + // Call - TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue.ToString(CultureInfo.InvariantCulture); + properties.Structure = null; // Assert - var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - - mockRepository.VerifyAll(); + Assert.IsTrue(properties.AfterSettingStructureCalled); } [Test] - public void SetStructure_NullValue_AfterSettingStructureCalled() + public void SetStructure_ValidValue_AfterSettingStructureCalled() { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -291,14 +289,16 @@ Assert.IsFalse(properties.AfterSettingStructureCalled); // Call - properties.Structure = null; + properties.Structure = new SimpleStructure(); // Assert Assert.IsTrue(properties.AfterSettingStructureCalled); } [Test] - public void SetStructure_ValidValue_AfterSettingStructureCalled() + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) { // Setup var assessmentSectionStub = mockRepository.Stub(); @@ -315,14 +315,14 @@ Data = inputContext }; - // Precondition - Assert.IsFalse(properties.AfterSettingStructureCalled); - // Call - properties.Structure = new SimpleStructure(); + TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue.ToString(CultureInfo.InvariantCulture); // Assert - Assert.IsTrue(properties.AfterSettingStructureCalled); + var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); } [Test]