Index: Riskeer/Common/src/Riskeer.Common.Data/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResult.cs =================================================================== diff -u -r3504be0f64dfd5594e2347fdba6899bc2f0754f1 -r14e49d33e028678a53f848d2c2f33755c32afeff --- Riskeer/Common/src/Riskeer.Common.Data/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResult.cs (.../AdoptableWithProfileProbabilityFailureMechanismSectionResult.cs) (revision 3504be0f64dfd5594e2347fdba6899bc2f0754f1) +++ Riskeer/Common/src/Riskeer.Common.Data/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResult.cs (.../AdoptableWithProfileProbabilityFailureMechanismSectionResult.cs) (revision 14e49d33e028678a53f848d2c2f33755c32afeff) @@ -58,7 +58,7 @@ get => manualInitialFailureMechanismResultProfileProbability; set { - ValidateInitialProfileProbability(value); + ValidateFailureProbability(value); manualInitialFailureMechanismResultProfileProbability = value; } } @@ -81,45 +81,9 @@ get => refinedProfileProbability; set { - ValidateRefinedProfileProbability(value); + ValidateFailureProbability(value); refinedProfileProbability = value; } } - - private void ValidateInitialProfileProbability(double value) - { - ValidateFailureProbability(value); - ValidateProbabilities(value, ManualInitialFailureMechanismResultSectionProbability, - RiskeerCommonDataResources.WithProfileProbabilityFailureMechanismSectionResult_ManualInitialFailureMechanismResultSectionProbability_must_be_greater_than_ManualInitialFailureMechanismResultProfileProbability); - } - - protected override void ValidateInitialSectionProbability(double value) - { - base.ValidateInitialSectionProbability(value); - ValidateProbabilities(ManualInitialFailureMechanismResultProfileProbability, value, - RiskeerCommonDataResources.WithProfileProbabilityFailureMechanismSectionResult_ManualInitialFailureMechanismResultSectionProbability_must_be_greater_than_ManualInitialFailureMechanismResultProfileProbability); - } - - private void ValidateRefinedProfileProbability(double value) - { - ValidateFailureProbability(value); - ValidateProbabilities(value, RefinedSectionProbability, - RiskeerCommonDataResources.WithProfileProbabilityFailureMechanismSectionResult_RefinedSectionProbability_must_be_greater_than_RefinedProfileProbability); - } - - protected override void ValidateRefinedSectionProbability(double value) - { - base.ValidateRefinedSectionProbability(value); - ValidateProbabilities(RefinedProfileProbability, value, - RiskeerCommonDataResources.WithProfileProbabilityFailureMechanismSectionResult_RefinedSectionProbability_must_be_greater_than_RefinedProfileProbability); - } - - private static void ValidateProbabilities(double profileProbability, double sectionProbability, string errorMessage) - { - if (profileProbability > sectionProbability) - { - throw new ArgumentOutOfRangeException(null, errorMessage); - } - } } } \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Data.Test/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResultTest.cs =================================================================== diff -u -r3504be0f64dfd5594e2347fdba6899bc2f0754f1 -r14e49d33e028678a53f848d2c2f33755c32afeff --- Riskeer/Common/test/Riskeer.Common.Data.Test/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResultTest.cs (.../AdoptableWithProfileProbabilityFailureMechanismSectionResultTest.cs) (revision 3504be0f64dfd5594e2347fdba6899bc2f0754f1) +++ Riskeer/Common/test/Riskeer.Common.Data.Test/FailureMechanism/AdoptableWithProfileProbabilityFailureMechanismSectionResultTest.cs (.../AdoptableWithProfileProbabilityFailureMechanismSectionResultTest.cs) (revision 14e49d33e028678a53f848d2c2f33755c32afeff) @@ -67,92 +67,12 @@ } [Test] - [TestCase(0.2)] - [TestCase(0.1 + 1e-5)] - public void GivenValidSectionResult_WhenSettingInitialProfileProbabilityGreaterThanSectionProbability_ThenArgumentOutOfRangeExceptionThrown(double invalidProbability) - { - // Given - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section) - { - ManualInitialFailureMechanismResultSectionProbability = 0.1 - }; - - // When - void Call() => result.ManualInitialFailureMechanismResultProfileProbability = invalidProbability; - - // Then - const string message = "De faalkans van het initiële mechanisme per doorsnede moet kleiner of gelijk zijn aan de faalkans van het initiële mechanisme per vak."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] - [SetCulture("nl-NL")] - [TestCase(-20)] - [TestCase(-1e-6)] - [TestCase(1 + 1e-6)] - [TestCase(12)] - public void ManualInitialFailureMechanismResultSectionProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double newValue) - { - // Setup - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section); - - // Call - void Call() => result.ManualInitialFailureMechanismResultSectionProbability = newValue; - - // Assert - const string message = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] [TestCase(0)] [TestCase(1e-6)] [TestCase(0.5)] [TestCase(1 - 1e-6)] [TestCase(1)] [TestCase(double.NaN)] - public void ManualInitialFailureMechanismResultSectionProbability_ValidValue_NewValueSet(double newValue) - { - // Setup - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section); - - // Call - result.ManualInitialFailureMechanismResultSectionProbability = newValue; - - // Assert - Assert.AreEqual(newValue, result.ManualInitialFailureMechanismResultSectionProbability); - } - - [Test] - [TestCase(0.2)] - [TestCase(0.3 - 1e-5)] - public void GivenValidSectionResult_WhenSettingInitialSectionProbabilitySmallerThanProfileProbability_ThenArgumentOutOfRangeExceptionThrown(double invalidProbability) - { - // Given - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section) - { - ManualInitialFailureMechanismResultProfileProbability = 0.3 - }; - - // When - void Call() => result.ManualInitialFailureMechanismResultSectionProbability = invalidProbability; - - // Then - const string message = "De faalkans van het initiële mechanisme per doorsnede moet kleiner of gelijk zijn aan de faalkans van het initiële mechanisme per vak."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] - [TestCase(0)] - [TestCase(1e-6)] - [TestCase(0.5)] - [TestCase(1 - 1e-6)] - [TestCase(1)] - [TestCase(double.NaN)] public void ManualInitialFailureMechanismResultProfileProbability_ValidValue_NewValueSet(double newValue) { // Setup @@ -187,92 +107,12 @@ } [Test] - [TestCase(0.2)] - [TestCase(0.1 + 1e-5)] - public void GivenValidSectionResult_WhenSettingRefinedProfileProbabilityGreaterThanSectionProbability_ThenArgumentOutOfRangeExceptionThrown(double invalidProbability) - { - // Given - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section) - { - RefinedSectionProbability = 0.1 - }; - - // When - void Call() => result.RefinedProfileProbability = invalidProbability; - - // Then - const string message = "De aangescherpte faalkans per doorsnede moet kleiner of gelijk zijn aan de aangescherpte faalkans per vak."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] - [SetCulture("nl-NL")] - [TestCase(-20)] - [TestCase(-1e-6)] - [TestCase(1 + 1e-6)] - [TestCase(12)] - public void RefinedSectionProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double newValue) - { - // Setup - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section); - - // Call - void Call() => result.RefinedSectionProbability = newValue; - - // Assert - const string message = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] [TestCase(0)] [TestCase(1e-6)] [TestCase(0.5)] [TestCase(1 - 1e-6)] [TestCase(1)] [TestCase(double.NaN)] - public void RefinedSectionProbability_ValidValue_NewValueSet(double newValue) - { - // Setup - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section); - - // Call - result.RefinedSectionProbability = newValue; - - // Assert - Assert.AreEqual(newValue, result.RefinedSectionProbability); - } - - [Test] - [TestCase(0.2)] - [TestCase(0.3 - 1e-5)] - public void GivenValidSectionResult_WhenSettingRefinedSectionProbabilitySmallerThanProfileProbability_ThenArgumentOutOfRangeExceptionThrown(double invalidProbability) - { - // Given - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new AdoptableWithProfileProbabilityFailureMechanismSectionResult(section) - { - RefinedProfileProbability = 0.3 - }; - - // When - void Call() => result.RefinedSectionProbability = invalidProbability; - - // Then - const string message = "De aangescherpte faalkans per doorsnede moet kleiner of gelijk zijn aan de aangescherpte faalkans per vak."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message); - } - - [Test] - [TestCase(0)] - [TestCase(1e-6)] - [TestCase(0.5)] - [TestCase(1 - 1e-6)] - [TestCase(1)] - [TestCase(double.NaN)] public void RefinedProfileProbability_ValidValue_NewValueSet(double newValue) { // Setup