Index: Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismAssemblyResultValidationHelper.cs
===================================================================
diff -u
--- Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismAssemblyResultValidationHelper.cs (revision 0)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismAssemblyResultValidationHelper.cs (revision 093f75950ed3ba89603f4dfb0e9ecaac5759376c)
@@ -0,0 +1,51 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Forms.Properties;
+
+namespace Riskeer.Common.Forms.Helpers
+{
+ ///
+ /// Class containing validation helper methods for a
+ ///
+ public static class FailureMechanismAssemblyResultValidationHelper
+ {
+ ///
+ /// Gets the validation error for a .
+ ///
+ /// The to get the validation messages for.
+ /// An error message when the validation fails or when there are no errors.
+ /// Thrown when is null.
+ public static string GetValidationError(FailureMechanismAssemblyResult result)
+ {
+ if (result == null)
+ {
+ throw new ArgumentNullException(nameof(result));
+ }
+
+ return result.IsManualProbability() && double.IsNaN(result.ManualFailureMechanismAssemblyProbability)
+ ? Resources.FailureProbability_must_not_be_NaN
+ : string.Empty;
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 093f75950ed3ba89603f4dfb0e9ecaac5759376c refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailurePathAssemblyResultValidationHelper.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Common/src/Riskeer.Common.Forms/Views/FailureMechanismResultView.cs
===================================================================
diff -u -rba639d608bbfcd02a294acfa6c428d41f2e627ce -r093f75950ed3ba89603f4dfb0e9ecaac5759376c
--- Riskeer/Common/src/Riskeer.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision ba639d608bbfcd02a294acfa6c428d41f2e627ce)
+++ Riskeer/Common/src/Riskeer.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 093f75950ed3ba89603f4dfb0e9ecaac5759376c)
@@ -370,7 +370,7 @@
FailureMechanismAssemblyResult assemblyResult = FailureMechanism.AssemblyResult;
if (assemblyResult.IsManualProbability())
{
- SetErrorMessage(FailurePathAssemblyResultValidationHelper.GetValidationError(assemblyResult));
+ SetErrorMessage(FailureMechanismAssemblyResultValidationHelper.GetValidationError(assemblyResult));
}
}
Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismAssemblyResultValidationHelperTest.cs
===================================================================
diff -u
--- Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismAssemblyResultValidationHelperTest.cs (revision 0)
+++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismAssemblyResultValidationHelperTest.cs (revision 093f75950ed3ba89603f4dfb0e9ecaac5759376c)
@@ -0,0 +1,94 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 NUnit.Framework;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Forms.Helpers;
+
+namespace Riskeer.Common.Forms.Test.Helpers
+{
+ [TestFixture]
+ public class FailureMechanismAssemblyResultValidationHelperTest
+ {
+ [Test]
+ public void GetValidationError_ResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => FailureMechanismAssemblyResultValidationHelper.GetValidationError(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("result", exception.ParamName);
+ }
+
+ [Test]
+ public void GetValidationError_WithResultManualAndInvalidProbability_ReturnsErrorMessage()
+ {
+ // Setup
+ var result = new FailureMechanismAssemblyResult
+ {
+ ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Manual,
+ ManualFailureMechanismAssemblyProbability = double.NaN
+ };
+
+ // Call
+ string message = FailureMechanismAssemblyResultValidationHelper.GetValidationError(result);
+
+ // Assert
+ Assert.AreEqual("Er moet een waarde worden ingevuld voor de faalkans.", message);
+ }
+
+ [Test]
+ public void GetValidationError_WithResultManualAndValidProbability_ReturnsEmptyMessage()
+ {
+ // Setup
+ var random = new Random(21);
+ var result = new FailureMechanismAssemblyResult
+ {
+ ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Manual,
+ ManualFailureMechanismAssemblyProbability = random.NextDouble()
+ };
+
+ // Call
+ string message = FailureMechanismAssemblyResultValidationHelper.GetValidationError(result);
+
+ // Assert
+ Assert.IsEmpty(message);
+ }
+
+ [Test]
+ public void GetValidationError_WithResultAutomatic_ReturnsEmptyMessage()
+ {
+ // Setup
+ var result = new FailureMechanismAssemblyResult
+ {
+ ProbabilityResultType = FailureMechanismAssemblyProbabilityResultType.Automatic
+ };
+
+ // Call
+ string message = FailureMechanismAssemblyResultValidationHelper.GetValidationError(result);
+
+ // Assert
+ Assert.IsEmpty(message);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 093f75950ed3ba89603f4dfb0e9ecaac5759376c refers to a dead (removed) revision in file `Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailurePathAssemblyResultValidationHelperTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Factories/FailureMechanismAssemblyResultRowFactory.cs
===================================================================
diff -u -rba639d608bbfcd02a294acfa6c428d41f2e627ce -r093f75950ed3ba89603f4dfb0e9ecaac5759376c
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Factories/FailureMechanismAssemblyResultRowFactory.cs (.../FailureMechanismAssemblyResultRowFactory.cs) (revision ba639d608bbfcd02a294acfa6c428d41f2e627ce)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Factories/FailureMechanismAssemblyResultRowFactory.cs (.../FailureMechanismAssemblyResultRowFactory.cs) (revision 093f75950ed3ba89603f4dfb0e9ecaac5759376c)
@@ -66,7 +66,7 @@
{
FailureMechanismAssemblyResult assemblyResult = failureMechanism.AssemblyResult;
- string validationError = FailurePathAssemblyResultValidationHelper.GetValidationError(assemblyResult);
+ string validationError = FailureMechanismAssemblyResultValidationHelper.GetValidationError(assemblyResult);
return !string.IsNullOrEmpty(validationError)
? new FailureMechanismAssemblyResultRow(failureMechanism, validationError)
: new FailureMechanismAssemblyResultRow(failureMechanism, assemblyResult.ManualFailureMechanismAssemblyProbability);