Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs =================================================================== diff -u -race63dd1e2a052cb8774347958f3f2e2013c7400 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs (.../IllustrationPointNodeCreateExtensionsTest.cs) (revision ace63dd1e2a052cb8774347958f3f2e2013c7400) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/IllustrationPointNodeCreateExtensionsTest.cs (.../IllustrationPointNodeCreateExtensionsTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -139,7 +139,7 @@ // Setup var random = new Random(21); - var illustrationPoint = new FaultTreeIllustrationPoint("Illustration point name", + var illustrationPoint = new FaultTreeIllustrationPoint("Illustration point name A", random.NextDouble(), Enumerable.Empty(), random.NextEnumValue()); @@ -164,32 +164,32 @@ { yield return new TestCaseData(new List { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }).SetName("SubMechanismIllustrationPoints"); yield return new TestCaseData(new List { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("B")) }).SetName("SubMechanismAndFaultTreeIllustrationPoints"); yield return new TestCaseData(new List { - new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()), - new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()) + new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("A")), + new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("B")) }).SetName("FaultTreeIllustrationPoints"); - var node = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()); + var node = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("A")); node.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")), + new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("C")) }); yield return new TestCaseData(new List { - new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()), + new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd("AA")), node }).SetName("FaultTreeIllustrationPointsWithChildren"); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs =================================================================== diff -u -r699aed8b7cadb16fa905b2e54c8174d0d5747b99 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs (.../TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs) (revision 699aed8b7cadb16fa905b2e54c8174d0d5747b99) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs (.../TopLevelFaultTreeIllustrationPointCreateExtensionsTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -80,8 +80,8 @@ var illustrationPointNode = new IllustrationPointNode(FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("0")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("1")) }); var topLevelIllustrationPoint = new TopLevelFaultTreeIllustrationPoint( @@ -103,9 +103,9 @@ entity.FaultTreeIllustrationPointEntity.SubMechanismIllustrationPointEntities.ToArray(); Assert.AreEqual(2, subMechanismIllustrationPointEntities.Length); - var expectedIllustrationPoint = new TestSubMechanismIllustrationPoint(); for (var i = 0; i < 2; i++) { + var expectedIllustrationPoint = new TestSubMechanismIllustrationPoint(i.ToString()); SubMechanismIllustrationPointEntity illustrationPointEntity = subMechanismIllustrationPointEntities[i]; Assert.AreEqual(expectedIllustrationPoint.Name, illustrationPointEntity.Name); Assert.AreEqual(expectedIllustrationPoint.Beta, illustrationPointEntity.Beta, expectedIllustrationPoint.Beta.GetAccuracy()); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs =================================================================== diff -u -r31f59cfc48a6839453e372572d03ecc6ae6f0d00 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision 31f59cfc48a6839453e372572d03ecc6ae6f0d00) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (.../RingtoetsProjectTestHelperTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -439,9 +439,9 @@ Assert.AreEqual(0.5, faultTreeIllustrationPoint.Beta, faultTreeIllustrationPoint.Beta.GetAccuracy()); Stochast innerStochast = faultTreeIllustrationPoint.Stochasts.Single(); - Assert.AreEqual("FaultTreeIllustrationPoint stochast", innerStochast.Name); - Assert.AreEqual(2.58, innerStochast.Alpha, innerStochast.Alpha.GetAccuracy()); - Assert.AreEqual(1, innerStochast.Duration, innerStochast.Duration.GetAccuracy()); + Assert.AreEqual("Stochast", innerStochast.Name); + Assert.AreEqual(0.9, innerStochast.Alpha, innerStochast.Alpha.GetAccuracy()); + Assert.AreEqual(0.1, innerStochast.Duration, innerStochast.Duration.GetAccuracy()); } #region Hydraulic Boundary Database Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -r31f59cfc48a6839453e372572d03ecc6ae6f0d00 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 31f59cfc48a6839453e372572d03ecc6ae6f0d00) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -456,7 +456,7 @@ 0.5, new[] { - new Stochast("FaultTreeIllustrationPoint stochast", 1, 2.58) + new Stochast("Stochast", 0.1, 0.9) }, CombinationType.And )) ) Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs =================================================================== diff -u -r90c8c7af20b188d787a29c8e5fcd03823009f209 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision 90c8c7af20b188d787a29c8e5fcd03823009f209) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -22,6 +22,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.IllustrationPoints { @@ -52,6 +54,8 @@ throw new ArgumentNullException(nameof(stochasts)); } + ValidateStochasts(stochasts); + CombinationType = combinationType; Stochasts = stochasts; } @@ -74,5 +78,14 @@ return clone; } + + private static void ValidateStochasts(IEnumerable stochasts) + { + bool hasNonDistinctStochasts = stochasts.AnyNonDistinct(s => s.Name); + if (hasNonDistinctStochasts) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_stochasts)); + } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs =================================================================== diff -u -re0c69303985f5ad57106c5b7f18700d1a16ae3b3 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision e0c69303985f5ad57106c5b7f18700d1a16ae3b3) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResult.cs (.../GeneralResult.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -61,6 +61,11 @@ throw new ArgumentNullException(nameof(topLevelIllustrationPoints)); } + IEnumerable points = topLevelIllustrationPoints.OfType(); + if (points.Any()) + { + ValidateStochastInChildren(points, stochasts); + } ValidateStochasts(stochasts); ValidateTopLevelIllustrationPoints(topLevelIllustrationPoints); @@ -95,6 +100,45 @@ return clone; } + private void ValidateStochastInChildren(IEnumerable topLevelFaultTreeIllustrationPoints, IEnumerable stochasts) + { + var childStochastNames = new List(); + + foreach (TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint in topLevelFaultTreeIllustrationPoints) + { + IllustrationPointNode nodeRoot = topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot; + childStochastNames.AddRange(GetStochastNamesFromChildren(nodeRoot)); + } + childStochastNames = childStochastNames.Distinct().ToList(); + IEnumerable topLevelStochastNames = stochasts.Select(s => s.Name); + + if (childStochastNames.Except(topLevelStochastNames).Any()) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_with_incorrect_top_level_stochasts)); + } + } + + private IEnumerable GetStochastNamesFromChildren(IllustrationPointNode nodeRoot) + { + var stochastNames = new List(); + var faultTreeData = nodeRoot.Data as FaultTreeIllustrationPoint; + if (faultTreeData != null) + { + stochastNames.AddRange(faultTreeData.Stochasts.Select(s => s.Name)); + foreach (IllustrationPointNode illustrationPointNode in nodeRoot.Children) + { + stochastNames.AddRange(GetStochastNamesFromChildren(illustrationPointNode)); + } + return stochastNames; + } + var subMechanismData = nodeRoot.Data as SubMechanismIllustrationPoint; + if (subMechanismData != null) + { + stochastNames.AddRange(subMechanismData.Stochasts.Select(s => s.Name)); + } + return stochastNames; + } + private static void ValidateTopLevelIllustrationPoints(IEnumerable topLevelIllustrationPoints) { bool hasNonDistinctIllustrationPointsPerWindDirection = Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs =================================================================== diff -u -r90c8c7af20b188d787a29c8e5fcd03823009f209 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs (.../IllustrationPointNode.cs) (revision 90c8c7af20b188d787a29c8e5fcd03823009f209) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs (.../IllustrationPointNode.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Core.Common.Utils.Extensions; using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.IllustrationPoints @@ -79,6 +80,13 @@ throw new ArgumentException(Resources.IllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes, nameof(children)); } + + var faultTreeData = Data as FaultTreeIllustrationPoint; + if (faultTreeData != null) + { + ValidateChildren(faultTreeData, children); + } + Children = children; } @@ -91,5 +99,36 @@ return clone; } + + private static void ValidateChildren(FaultTreeIllustrationPoint data, IEnumerable children) + { + // Validate child names + IEnumerable illustrationPointNodes = children as IList ?? children.ToList(); + if (illustrationPointNodes.AnyNonDistinct(c => c.Data.Name)) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_child_names)); + } + + // Validate child stochasts + var stochastNames = new List(); + foreach (IllustrationPointNode illustrationPointNode in illustrationPointNodes) + { + var faultTreeData = illustrationPointNode.Data as FaultTreeIllustrationPoint; + if (faultTreeData != null) + { + stochastNames.AddRange(faultTreeData.Stochasts.Select(s => s.Name)); + continue; + } + var subMechanismData = illustrationPointNode.Data as SubMechanismIllustrationPoint; + if (subMechanismData != null) + { + stochastNames.AddRange(subMechanismData.Stochasts.Select(s => s.Name)); + } + } + if (data.Stochasts.Select(s => s.Name).Intersect(stochastNames).Count() != stochastNames.Distinct().Count()) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_with_incorrect_top_level_stochasts)); + } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/SubMechanismIllustrationPoint.cs =================================================================== diff -u -r90c8c7af20b188d787a29c8e5fcd03823009f209 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/SubMechanismIllustrationPoint.cs (.../SubMechanismIllustrationPoint.cs) (revision 90c8c7af20b188d787a29c8e5fcd03823009f209) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/SubMechanismIllustrationPoint.cs (.../SubMechanismIllustrationPoint.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -22,6 +22,8 @@ using System; using System.Collections.Generic; using System.Linq; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.IllustrationPoints { @@ -37,6 +39,7 @@ /// The beta value that was realized. /// The stochasts for the sub mechanism illustration point. /// The output variables. + /// Thrown when the names of the are not unique. /// Thrown when any of: /// /// @@ -59,6 +62,9 @@ throw new ArgumentNullException(nameof(illustrationPointResults)); } + ValidateStochasts(stochasts); + ValidateResults(illustrationPointResults); + Stochasts = stochasts; IllustrationPointResults = illustrationPointResults; } @@ -82,5 +88,23 @@ return clone; } + + private static void ValidateResults(IEnumerable illustrationPointResults) + { + bool nonDistinct = illustrationPointResults.AnyNonDistinct(i => i.Description); + if (nonDistinct) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_results)); + } + } + + private static void ValidateStochasts(IEnumerable stochasts) + { + bool hasNonDistinctStochasts = stochasts.AnyNonDistinct(s => s.Name); + if (hasNonDistinctStochasts) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_stochasts)); + } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs =================================================================== diff -u -re0c69303985f5ad57106c5b7f18700d1a16ae3b3 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e0c69303985f5ad57106c5b7f18700d1a16ae3b3) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -555,6 +555,15 @@ } /// + /// Looks up a localized string similar to Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.. + /// + public static string GeneralResult_Imported_non_unique_child_names { + get { + return ResourceManager.GetString("GeneralResult_Imported_non_unique_child_names", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslagen.. /// public static string GeneralResult_Imported_non_unique_closing_situations_or_wind_direction { @@ -564,6 +573,15 @@ } /// + /// Looks up a localized string similar to Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.. + /// + public static string GeneralResult_Imported_non_unique_results { + get { + return ResourceManager.GetString("GeneralResult_Imported_non_unique_results", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.. /// public static string GeneralResult_Imported_non_unique_stochasts { @@ -573,6 +591,15 @@ } /// + /// Looks up a localized string similar to De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. Het uitlezen van illustratiepunten wordt overgeslagen.. + /// + public static string GeneralResult_Imported_with_incorrect_top_level_stochasts { + get { + return ResourceManager.GetString("GeneralResult_Imported_with_incorrect_top_level_stochasts", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Hydraulische randvoorwaarden. /// public static string HydraulicBoundaryConditions_DisplayName { Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx =================================================================== diff -u -re0c69303985f5ad57106c5b7f18700d1a16ae3b3 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision e0c69303985f5ad57106c5b7f18700d1a16ae3b3) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -393,4 +393,13 @@ Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslagen. + + Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen. + + + De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. Het uitlezen van illustratiepunten wordt overgeslagen. + + + Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r72e8e672bbfb506c8a9b71b8999591bae5cbafe7 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 72e8e672bbfb506c8a9b71b8999591bae5cbafe7) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -301,6 +301,15 @@ } /// + /// Looks up a localized string similar to Fout bij het uitlezen van de illustratiepunten voor berekening {0}:. + /// + public static string SetGeneralResult_Error_while_converting_generalresult { + get { + return ResourceManager.GetString("SetGeneralResult_Error_while_converting_generalresult", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Er is geen kunstwerk geselecteerd.. /// public static string StructuresCalculationService_ValidateInput_No_Structure_selected { Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx =================================================================== diff -u -r72e8e672bbfb506c8a9b71b8999591bae5cbafe7 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 72e8e672bbfb506c8a9b71b8999591bae5cbafe7) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -215,4 +215,7 @@ Er is een fout opgetreden tijdens de golfhoogte berekening '{0}'. Er is geen foutrapport beschikbaar. + + Fout bij het uitlezen van de illustratiepunten voor berekening {0}: + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs =================================================================== diff -u -r21f9de0d12327b2d4319a2e78055d11c66cc7300 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 21f9de0d12327b2d4319a2e78055d11c66cc7300) +++ Ringtoets/Common/src/Ringtoets.Common.Service/Structures/StructuresCalculationServiceBase.cs (.../StructuresCalculationServiceBase.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -273,10 +273,18 @@ private void SetOutput(StructuresCalculation calculation, ProbabilityAssessmentOutput probabilityAssessmentOutput) { - GeneralResult generalResult = - calculation.InputParameters.ShouldIllustrationPointsBeCalculated - ? GetGeneralResult(calculator.IllustrationPointsResult) - : null; + GeneralResult generalResult = null; + try + { + generalResult = + calculation.InputParameters.ShouldIllustrationPointsBeCalculated + ? GetGeneralResult(calculator.IllustrationPointsResult) + : null; + } + catch (ArgumentException e) + { + log.Warn(string.Format(Resources.SetGeneralResult_Error_while_converting_generalresult, calculation.Name) + " " + e.Message); + } calculation.Output = new StructuresOutput(probabilityAssessmentOutput, generalResult); } Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs =================================================================== diff -u -r268c1647f0094f6c43aeceaa5793437562cffe5a -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs (.../FaultTreeIllustrationPointTest.cs) (revision 268c1647f0094f6c43aeceaa5793437562cffe5a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs (.../FaultTreeIllustrationPointTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -86,6 +86,33 @@ } [Test] + public void Constructor_StochastNotUnique_ThrowArgumentException() + { + // Setup + var random = new Random(21); + var stochasts = new[] + { + new Stochast("unique", 0, 0), + new Stochast("non-unique", 0, 0), + new Stochast("non-unique", 0, 0), + new Stochast("nonunique", 0, 0), + new Stochast("nonunique", 0, 0) + }; + + // Call + TestDelegate test = () => new FaultTreeIllustrationPoint("Point A", + random.NextDouble(), + stochasts, + CombinationType.And); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Een of meerdere stochasten hebben dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs =================================================================== diff -u -re0c69303985f5ad57106c5b7f18700d1a16ae3b3 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs (.../GeneralResultTest.cs) (revision e0c69303985f5ad57106c5b7f18700d1a16ae3b3) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultTest.cs (.../GeneralResultTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -131,7 +131,7 @@ } [Test] - public void Constructor_IllustrationPointsNotUnique_ThrowArgumentException() + public void Constructor_TopLevelIllustrationPointsNotUnique_ThrowArgumentException() { // Setup WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); @@ -155,6 +155,61 @@ } [Test] + public void Constructor_StochastsNotUnique_ThrowArgumentException() + { + // Setup + WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); + IEnumerable stochasts = new[] + { + new Stochast("Stochast 1", 0, 0), + new Stochast("Stochast 1", 0, 0) + }; + IEnumerable topLevelIllustrationPoints = new List(); + + // Call + TestDelegate test = () => new GeneralResult(windDirection, + stochasts, + topLevelIllustrationPoints); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Een of meerdere stochasten hebben dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] + public void Constructor_ChildStochastsNotInStochasts_ThrowArgumentException() + { + // Setup + WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); + IEnumerable stochasts = new[] + { + new Stochast("Stochast 1", 0, 0) + }; + var illustrationPointNode = new IllustrationPointNode(new FaultTreeIllustrationPoint("A", 0.0, new [] + { + new Stochast("Stochast 2", 0, 0) + }, CombinationType.And)); + + IEnumerable topLevelIllustrationPoints = new List + { + new TopLevelFaultTreeIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "closing", illustrationPointNode) + }; + + // Call + TestDelegate test = () => new GeneralResult(windDirection, + stochasts, + topLevelIllustrationPoints); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs =================================================================== diff -u -r268c1647f0094f6c43aeceaa5793437562cffe5a -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs (.../IllustrationPointNodeTest.cs) (revision 268c1647f0094f6c43aeceaa5793437562cffe5a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs (.../IllustrationPointNodeTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -112,6 +112,59 @@ } [Test] + public void SetChildren_ChildNamesNotUnique_ThrowArgumentException() + { + // Setup + var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint("Top")); + var childrenToBeAdded = new[] + { + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")) + }; + + // Call + TestDelegate test = () => illustrationPointNode.SetChildren(childrenToBeAdded); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] + public void SetChildren_ChildContainsDifferentStochasts_ThrowArgumentException() + { + // Setup + var illustrationPointNode = new IllustrationPointNode(new FaultTreeIllustrationPoint("Top", + 0.0, + new[] + { + new Stochast("Stochast A", 0, 0) + }, + CombinationType.And)); + var childrenToBeAdded = new[] + { + new IllustrationPointNode(new FaultTreeIllustrationPoint("A", + 0.0, + new[] + { + new Stochast("Stochast B", 0, 0) + }, CombinationType.Or)), + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("B")) + }; + + // Call + TestDelegate test = () => illustrationPointNode.SetChildren(childrenToBeAdded); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/SubMechanismIllustrationPointTest.cs =================================================================== diff -u -r268c1647f0094f6c43aeceaa5793437562cffe5a -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/SubMechanismIllustrationPointTest.cs (.../SubMechanismIllustrationPointTest.cs) (revision 268c1647f0094f6c43aeceaa5793437562cffe5a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/SubMechanismIllustrationPointTest.cs (.../SubMechanismIllustrationPointTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -112,6 +112,58 @@ } [Test] + public void Constructor_StochastNotUnique_ThrowArgumentException() + { + // Setup + var random = new Random(21); + var stochasts = new[] + { + new SubMechanismIllustrationPointStochast("unique", 0, 0, 0), + new SubMechanismIllustrationPointStochast("non-unique", 0, 0, 0), + new SubMechanismIllustrationPointStochast("non-unique", 0, 0, 0), + new SubMechanismIllustrationPointStochast("nonunique", 0, 0, 0), + new SubMechanismIllustrationPointStochast("nonunique", 0, 0, 0) + }; + + // Call + TestDelegate test = () => new SubMechanismIllustrationPoint("Point A", + random.NextDouble(), + stochasts, + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Een of meerdere stochasten hebben dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] + public void Constructor_IllustrationPointResultsNotUnique_ThrowArgumentException() + { + // Setup + var random = new Random(21); + var results = new[] + { + new IllustrationPointResult("non-unique", 0), + new IllustrationPointResult("non-unique", 0), + new IllustrationPointResult("unique", 0) + }; + + // Call + TestDelegate test = () => new SubMechanismIllustrationPoint("Point A", + random.NextDouble(), + Enumerable.Empty(), + results); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Een of meerdere resultaten hebben dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", + exception.Message); + } + + [Test] public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/FaultTreeIllustrationPointTestFactoryTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/FaultTreeIllustrationPointTestFactoryTest.cs (.../FaultTreeIllustrationPointTestFactoryTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/FaultTreeIllustrationPointTestFactoryTest.cs (.../FaultTreeIllustrationPointTestFactoryTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -63,7 +63,7 @@ } [Test] - public void CreateTestFaultTreeIllustrationPointCombinationTypeAnd_ValidParameter_ReturnsExpectedProperties() + public void CreateTestFaultTreeIllustrationPointCombinationTypeAnd_ValidBetaParameter_ReturnsExpectedProperties() { // Setup double beta = new Random().NextDouble(); @@ -81,6 +81,24 @@ } [Test] + public void CreateTestFaultTreeIllustrationPointCombinationTypeAnd_ValidNameParameter_ReturnsExpectedProperties() + { + // Setup + const string name = "Random name"; + + // Call + FaultTreeIllustrationPoint illustrationPoint = FaultTreeIllustrationPointTestFactory.CreateTestFaultTreeIllustrationPointCombinationTypeAnd(name); + + // Assert + Assert.IsInstanceOf(illustrationPoint); + + Assert.AreEqual(name, illustrationPoint.Name); + Assert.AreEqual(1.23, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy()); + Assert.AreEqual(CombinationType.And, illustrationPoint.CombinationType); + CollectionAssert.IsEmpty(illustrationPoint.Stochasts); + } + + [Test] public void CreateTestFaultTreeIllustrationPointCombinationTypeOr_ValidParameter_ReturnsExpectedProperties() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/FaultTreeIllustrationPointTestFactory.cs =================================================================== diff -u -r355b0e8dff79cfc8a42cf598f24a753ba5f57083 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/FaultTreeIllustrationPointTestFactory.cs (.../FaultTreeIllustrationPointTestFactory.cs) (revision 355b0e8dff79cfc8a42cf598f24a753ba5f57083) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/FaultTreeIllustrationPointTestFactory.cs (.../FaultTreeIllustrationPointTestFactory.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -66,6 +66,20 @@ /// /// Creates a new instance of with + /// set to . + /// + /// The name of the illustration point. + /// The created . + public static FaultTreeIllustrationPoint CreateTestFaultTreeIllustrationPointCombinationTypeAnd(string name) + { + return new FaultTreeIllustrationPoint(name, + 1.23, + Enumerable.Empty(), + CombinationType.And); + } + + /// + /// Creates a new instance of with /// set to . /// /// The beta value of the illustration point. Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FaultTreeIllustrationPointPropertiesTest.cs =================================================================== diff -u -rdf0dfaac54b07c9d3dc72b6db2d97f090b971314 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FaultTreeIllustrationPointPropertiesTest.cs (.../FaultTreeIllustrationPointPropertiesTest.cs) (revision df0dfaac54b07c9d3dc72b6db2d97f090b971314) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FaultTreeIllustrationPointPropertiesTest.cs (.../FaultTreeIllustrationPointPropertiesTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -107,14 +107,21 @@ stochast }, CombinationType.And)); - var illustrationPointNodeChild = new IllustrationPointNode(new FaultTreeIllustrationPoint("Fault tree child", - 3.5, - new Stochast[0], - CombinationType.Or)); + var illustrationPointNodeChild1 = new IllustrationPointNode(new FaultTreeIllustrationPoint("Fault tree child", + 3.5, + new[] + { + stochast + }, + CombinationType.Or)); + var illustrationPointNodeChild2 = new IllustrationPointNode(new FaultTreeIllustrationPoint("Fault tree child 2", + 3.5, + new Stochast[0], + CombinationType.Or)); var illustrationPointNodeChildren = new[] { - illustrationPointNodeChild, - illustrationPointNodeChild + illustrationPointNodeChild1, + illustrationPointNodeChild2 }; illustrationPointNode.SetChildren(illustrationPointNodeChildren); @@ -170,8 +177,8 @@ var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); // Call @@ -238,8 +245,8 @@ var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); // Call Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs =================================================================== diff -u -rdf0dfaac54b07c9d3dc72b6db2d97f090b971314 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs (.../IllustrationPointPropertiesTest.cs) (revision df0dfaac54b07c9d3dc72b6db2d97f090b971314) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs (.../IllustrationPointPropertiesTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -192,8 +192,8 @@ var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { - new IllustrationPointNode(new TestFaultTreeIllustrationPoint()), - new IllustrationPointNode(new TestFaultTreeIllustrationPoint()) + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("B")) }); // Call @@ -288,8 +288,8 @@ var illustrationPointNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); illustrationPointNode.SetChildren(new[] { - new IllustrationPointNode(new TestFaultTreeIllustrationPoint()), - new IllustrationPointNode(new TestFaultTreeIllustrationPoint()) + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("B")) }); // Call Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelFaultTreeIllustrationPointPropertiesTest.cs =================================================================== diff -u -r2eab6260ad63e806b10647d64792294139dc2157 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelFaultTreeIllustrationPointPropertiesTest.cs (.../TopLevelFaultTreeIllustrationPointPropertiesTest.cs) (revision 2eab6260ad63e806b10647d64792294139dc2157) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelFaultTreeIllustrationPointPropertiesTest.cs (.../TopLevelFaultTreeIllustrationPointPropertiesTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -91,8 +91,8 @@ topLevel.FaultTreeNodeRoot.SetChildren(new[] { - new IllustrationPointNode(new TestFaultTreeIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); // Call Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs =================================================================== diff -u -r244dd8357f6de439ff2364fa675a9e128da84b5c -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -267,8 +267,8 @@ var faultTreeNodeRootWithChildren = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); faultTreeNodeRootWithChildren.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); return new GeneralResult(WindDirectionTestFactory.CreateTestWindDirection(), Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs =================================================================== diff -u -r09657885dd6a95975a8e117f8b8c570cd84a2523 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs (.../IllustrationPointsFaultTreeControlTest.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs (.../IllustrationPointsFaultTreeControlTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -66,8 +66,8 @@ var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); rootNode.SetChildren(new[] { - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()), - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("A")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); control.Data = new TopLevelFaultTreeIllustrationPoint( @@ -150,11 +150,11 @@ { var illustrationPointNode = new IllustrationPointNode(new TestSubMechanismIllustrationPoint()); - var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); + var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")); rootNode.SetChildren(new[] { illustrationPointNode, - new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B")) }); control.Data = new TopLevelFaultTreeIllustrationPoint( @@ -177,43 +177,6 @@ } } - [Test] - [TestCase(2, TestName = "GivenControlWithDuplicatedData_WhenVertex2Selected_SelectionSetToCorrespondingIllustrationPointNode")] - [TestCase(3, TestName = "GivenControlWithDuplicatedData_WhenVertex3Selected_SelectionSetToCorrespondingIllustrationPointNode")] - public void GivenControlWithDuplicatedData_WhenVertexSelected_SelectionSetToCorrespondingIllustrationPointNodeSelectionChangedFired(int vertexIndex) - { - // Given - using (var control = new IllustrationPointsFaultTreeControl()) - { - var illustrationPointNode = new IllustrationPointNode(new TestSubMechanismIllustrationPoint()); - - var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); - rootNode.SetChildren(new[] - { - illustrationPointNode, - illustrationPointNode - }); - - control.Data = new TopLevelFaultTreeIllustrationPoint( - WindDirectionTestFactory.CreateTestWindDirection(), - "closing situation", - rootNode); - - var selectionChanged = 0; - control.SelectionChanged += (sender, args) => selectionChanged++; - - PointedTreeElementVertex selectedVertex = GetPointedTreeGraph(control).Vertices.ElementAt(vertexIndex); - - // When - selectedVertex.IsSelected = true; - - // Then - object selection = control.Selection; - Assert.AreSame(illustrationPointNode, selection); - Assert.AreEqual(1, selectionChanged); - } - } - private static PointedTreeGraph GetPointedTreeGraph(IllustrationPointsFaultTreeControl control) { var pointedTreeGraphControl = TypeUtils.GetField(control, "pointedTreeGraphControl"); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs =================================================================== diff -u -r624182c7e9be3e758f0c6a55e360edac0892d48e -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs (.../IllustrationPointNodeConverterTest.cs) (revision 624182c7e9be3e758f0c6a55e360edac0892d48e) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs (.../IllustrationPointNodeConverterTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -130,14 +130,14 @@ var nestedHydraRingIllustrationPointTreeNodes = new HydraRingIllustrationPointTreeNode(new TestHydraRingFaultTreeIllustrationPoint()); nestedHydraRingIllustrationPointTreeNodes.SetChildren(new[] { - new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()), - new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()) + new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point A")), + new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point B")) }); var hydraRingIllustrationPointRootTreeNode = new HydraRingIllustrationPointTreeNode(new TestHydraRingFaultTreeIllustrationPoint()); hydraRingIllustrationPointRootTreeNode.SetChildren(new[] { - new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()), + new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint("Point C")), nestedHydraRingIllustrationPointTreeNodes }); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs =================================================================== diff -u -rc77ccbb8b26516270f36ef53110be573839f3470 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs (.../TopLevelFaultTreeIllustrationPointConverterTest.cs) (revision c77ccbb8b26516270f36ef53110be573839f3470) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs (.../TopLevelFaultTreeIllustrationPointConverterTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -143,7 +143,10 @@ var hydraRingFaultTreeIllustrationPointChildOne = new HydraRingFaultTreeIllustrationPoint("fault tree child one", random.NextDouble(), - Enumerable.Empty(), + new[] + { + hydraRingStochast + }, HydraRingCombinationType.Or); var hydraRingFaultTreeIllustrationPointChildTwo = new HydraRingSubMechanismIllustrationPoint("fault tree child two", @@ -186,7 +189,10 @@ CollectionAssert.IsEmpty(children[1].Children); var childOne = (FaultTreeIllustrationPoint) children[0].Data; - CollectionAssert.IsEmpty(childOne.Stochasts); + Stochast childStochast = illustrationPointData.Stochasts.Single(); + Assert.AreEqual(hydraRingStochast.Alpha, childStochast.Alpha, childStochast.Alpha.GetAccuracy()); + Assert.AreEqual(hydraRingStochast.Duration, childStochast.Duration, childStochast.Duration.GetAccuracy()); + Assert.AreEqual(hydraRingStochast.Name, childStochast.Name); Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildOne.Name, childOne.Name); Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildOne.Beta, childOne.Beta, childOne.Beta.GetAccuracy()); Assert.AreEqual(CombinationType.Or, childOne.CombinationType); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs =================================================================== diff -u -r85fcfb3e47d742a46200fcfb93f7cd4b155b9a94 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs (.../StructuresCalculationServiceBaseTest.cs) (revision 85fcfb3e47d742a46200fcfb93f7cd4b155b9a94) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Structures/StructuresCalculationServiceBaseTest.cs (.../StructuresCalculationServiceBaseTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Core.Common.Base.Geometry; @@ -37,6 +38,7 @@ using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data; using Ringtoets.HydraRing.Calculation.Data.Input; +using Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints; using Ringtoets.HydraRing.Calculation.Exceptions; using Ringtoets.HydraRing.Calculation.TestUtil; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; @@ -540,7 +542,7 @@ } [Test] - public void Calculate_ValidInputButIllustrationPointResultsInvalid_IllustrationPointsNotSetAndLogsWarning() + public void Calculate_ValidInputButIllustrationPointResultsOfIncorrectType_IllustrationPointsNotSetAndLogsWarning() { // Setup var mocks = new MockRepository(); @@ -597,6 +599,136 @@ } [Test] + public void Calculate_ValidInputButIllustrationPointResultsWithNonDistinctStochasts_IllustrationPointsNotSetAndLogsWarning() + { + // Setup + var mocks = new MockRepository(); + var stochasts = new[] + { + new Stochast("Stochast A", 0, 0), + new Stochast("Stochast A", 0, 0) + }; + var illustrationPoints = new Dictionary(); + var calculator = new TestStructuresCalculator + { + OutputDirectory = validFilePath, + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), stochasts, illustrationPoints) + }; + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator(testDataPath)) + .Return(calculator); + + const string performedCalculationMessage = "Calculation successful"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetCalculationPerformedMessage(validFilePath)).Return(performedCalculationMessage); + mocks.ReplayAll(); + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var calculation = new TestStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + ShouldIllustrationPointsBeCalculated = true + } + }; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + var service = new TestStructuresCalculationService(messageProvider); + + // Call + Action call = () => service.Calculate(calculation, new GeneralTestInput(), 1, 1, 1, validFilePath); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + Assert.AreEqual(4, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Fout bij het uitlezen van de illustratiepunten voor berekening Nieuwe berekening: " + + "Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.", msgs[1]); + Assert.AreEqual(performedCalculationMessage, msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + }); + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.HasGeneralResult); + } + mocks.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButIllustrationPointResultsWithNonDistinctIllustrationPoints_IllustrationPointsNotSetAndLogsWarning() + { + // Setup + var mocks = new MockRepository(); + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + }, + { + new WindDirectionClosingSituation(new WindDirection("S", 0.0), "closing A"), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + } + }; + var calculator = new TestStructuresCalculator + { + OutputDirectory = validFilePath, + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), Enumerable.Empty(), illustrationPoints) + }; + var calculatorFactory = mocks.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateStructuresCalculator(testDataPath)) + .Return(calculator); + + const string performedCalculationMessage = "Calculation successful"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetCalculationPerformedMessage(validFilePath)).Return(performedCalculationMessage); + mocks.ReplayAll(); + + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var calculation = new TestStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + ShouldIllustrationPointsBeCalculated = true + } + }; + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + var service = new TestStructuresCalculationService(messageProvider); + + // Call + Action call = () => service.Calculate(calculation, new GeneralTestInput(), 1, 1, 1, validFilePath); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + Assert.AreEqual(4, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Fout bij het uitlezen van de illustratiepunten voor berekening Nieuwe berekening: " + + "Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", msgs[1]); + Assert.AreEqual(performedCalculationMessage, msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + }); + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.HasGeneralResult); + } + mocks.VerifyAll(); + } + + [Test] public void Calculate_CancelCalculationWithValidInput_CancelsCalculatorAndHasNullOutput() { // Setup Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -rc3a3f5c0e40d0307e94fa6e77db291b41816c2fb -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision c3a3f5c0e40d0307e94fa6e77db291b41816c2fb) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -267,10 +267,18 @@ calculation.Name, Resources.GrassCoverErosionInwardsCalculationService_Overtopping); - GeneralResult generalResult = calculation.InputParameters.ShouldOvertoppingOutputIllustrationPointsBeCalculated - ? ConvertIllustrationPointsResult(overtoppingCalculator.IllustrationPointsResult, - overtoppingCalculator.IllustrationPointsParserErrorMessage) - : null; + GeneralResult generalResult = null; + try + { + generalResult = calculation.InputParameters.ShouldOvertoppingOutputIllustrationPointsBeCalculated + ? ConvertIllustrationPointsResult(overtoppingCalculator.IllustrationPointsResult, + overtoppingCalculator.IllustrationPointsParserErrorMessage) + : null; + } + catch (ArgumentException e) + { + log.Warn(string.Format(Resources.SetGeneralResult_Error_while_converting_generalresult_overtopping, calculation.Name) + " " + e.Message); + } var overtoppingOutput = new OvertoppingOutput(overtoppingCalculator.WaveHeight, overtoppingCalculator.IsOvertoppingDominant, @@ -658,10 +666,18 @@ calculationName)); } - GeneralResult generalResult = shouldIllustrationPointsBeCalculated - ? ConvertIllustrationPointsResult(calculator.IllustrationPointsResult, - calculator.IllustrationPointsParserErrorMessage) - : null; + GeneralResult generalResult = null; + try + { + generalResult = shouldIllustrationPointsBeCalculated + ? ConvertIllustrationPointsResult(calculator.IllustrationPointsResult, + calculator.IllustrationPointsParserErrorMessage) + : null; + } + catch (ArgumentException e) + { + log.Warn(string.Format(Resources.SetGeneralResult_Error_while_converting_generalresult_dike_height, calculationName) + " " + e.Message); + } return new DikeHeightOutput(dikeHeight, targetProbability, targetReliability, probability, reliability, @@ -700,10 +716,18 @@ calculationName)); } - GeneralResult generalResult = shouldIllustrationPointsBeCalculated - ? ConvertIllustrationPointsResult(calculator.IllustrationPointsResult, - calculator.IllustrationPointsParserErrorMessage) - : null; + GeneralResult generalResult = null; + try + { + generalResult = shouldIllustrationPointsBeCalculated + ? ConvertIllustrationPointsResult(calculator.IllustrationPointsResult, + calculator.IllustrationPointsParserErrorMessage) + : null; + } + catch (ArgumentException e) + { + log.Warn(string.Format(Resources.SetGeneralResult_Error_while_converting_generalresult_overtopping_rate, calculationName) + " " + e.Message); + } return new OvertoppingRateOutput(overtoppingRate, targetProbability, targetReliability, probability, reliability, Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r889e8e4ee8267b316e00e8f8a1035c60afb200a0 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 889e8e4ee8267b316e00e8f8a1035c60afb200a0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -158,5 +158,32 @@ return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_OvertoppingRate", resourceCulture); } } + + /// + /// Looks up a localized string similar to Fout bij het uitlezen van de HBN illustratiepunten voor berekening {0}:. + /// + internal static string SetGeneralResult_Error_while_converting_generalresult_dike_height { + get { + return ResourceManager.GetString("SetGeneralResult_Error_while_converting_generalresult_dike_height", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fout bij het uitlezen van de overloop en overslag illustratiepunten voor berekening {0}:. + /// + internal static string SetGeneralResult_Error_while_converting_generalresult_overtopping { + get { + return ResourceManager.GetString("SetGeneralResult_Error_while_converting_generalresult_overtopping", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fout bij het uitlezen van de overslagdebiet illustratiepunten voor berekening {0}:. + /// + internal static string SetGeneralResult_Error_while_converting_generalresult_overtopping_rate { + get { + return ResourceManager.GetString("SetGeneralResult_Error_while_converting_generalresult_overtopping_rate", resourceCulture); + } + } } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx =================================================================== diff -u -r889e8e4ee8267b316e00e8f8a1035c60afb200a0 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 889e8e4ee8267b316e00e8f8a1035c60afb200a0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -142,4 +142,13 @@ overslagdebiet + + Fout bij het uitlezen van de HBN illustratiepunten voor berekening {0}: + + + Fout bij het uitlezen van de overloop en overslag illustratiepunten voor berekening {0}: + + + Fout bij het uitlezen van de overslagdebiet illustratiepunten voor berekening {0}: + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs =================================================================== diff -u -r85fcfb3e47d742a46200fcfb93f7cd4b155b9a94 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 85fcfb3e47d742a46200fcfb93f7cd4b155b9a94) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Core.Common.Base.Data; @@ -38,6 +39,7 @@ using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Service.TestUtil; using Ringtoets.HydraRing.Calculation.Calculator.Factory; +using Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints; using Ringtoets.HydraRing.Calculation.Exceptions; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints; @@ -2080,7 +2082,7 @@ } [Test] - public void Calculate_ValidInputButOvertoppingIllustrationPointResultsInvalid_GeneralResultNotSetAndLogsWarning() + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsOfIncorrectType_GeneralResultNotSetAndLogsWarning() { // Setup GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); @@ -2164,25 +2166,635 @@ } [Test] - public void Calculate_ValidInputButOvertoppingRateIllustrationPointResultsInvalid_GeneralResultNotSetAndLogsWarning() + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithNonDistinctStochasts_GeneralResultNotSetAndLogsWarning() { // Setup GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); var mockRepository = new MockRepository(); + var stochasts = new[] + { + new Stochast("Stochast A", 0, 0), + new Stochast("Stochast A", 0, 0) + }; + var illustrationPoints = new Dictionary(); IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mockRepository, validFile); var overtoppingCalculator = new TestOvertoppingCalculator { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), stochasts, illustrationPoints) + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { IllustrationPointsResult = new TestGeneralResult() }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctStochasts( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithIncorrectTopLevelStochasts_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + var stochasts = new[] + { + new Stochast("Stochast A", 0, 0), + new Stochast("Stochast B", 0, 0) + }; + + var faultTreeNode1 = new IllustrationPointTreeNode(new FaultTreeIllustrationPoint("Point A", 0.0, new[] + { + new Stochast("Stochast C", 0, 0) + }, CombinationType.And)); + faultTreeNode1.SetChildren(new[] + { + new IllustrationPointTreeNode(new SubMechanismIllustrationPoint("Point C", new[] + { + new SubMechanismIllustrationPointStochast("Stochast C", 0, 0, 0) + }, Enumerable.Empty(), 0)), + new IllustrationPointTreeNode(new TestSubMechanismIllustrationPoint()) + }); + + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + faultTreeNode1 + } + }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), stochasts, illustrationPoints) + }; var dikeHeightCalculator = new TestHydraulicLoadsCalculator { IllustrationPointsResult = new TestGeneralResult() }; var overtoppingRateCalculator = new TestHydraulicLoadsCalculator { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultIncorrectTopLevelStochasts( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithIncorrectStochastsInChildren_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + var stochasts = new[] + { + new Stochast("Stochast A", 0, 0), + new Stochast("Stochast D", 0, 0) + }; + + var illustrationPointNode = new IllustrationPointTreeNode(new FaultTreeIllustrationPoint("Point A", 0.0, new[] + { + new Stochast("Stochast A", 0, 0) + }, CombinationType.And)); + illustrationPointNode.SetChildren(new[] + { + new IllustrationPointTreeNode(new SubMechanismIllustrationPoint("Point SA", new[] + { + new SubMechanismIllustrationPointStochast("Stochast D", 0, 0, 0) + }, Enumerable.Empty(), 0.0)), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + }); + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + illustrationPointNode + } + }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), stochasts, illustrationPoints) + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultIncorrectTopLevelStochasts( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithNonDistinctIllustrationPoints_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + }, + { + new WindDirectionClosingSituation(new WindDirection("S", 0.0), "closing A"), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + } + }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), Enumerable.Empty(), illustrationPoints) + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPoints( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithNonDistinctIllustrationPointResults_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + + var illustrationPointNode = new IllustrationPointTreeNode(new FaultTreeIllustrationPoint("Point A", 0.5, Enumerable.Empty(), CombinationType.And)); + illustrationPointNode.SetChildren(new[] + { + new IllustrationPointTreeNode(new SubMechanismIllustrationPoint("Point SA", Enumerable.Empty(), new[] + { + new IllustrationPointResult("Result A", 0.0), + new IllustrationPointResult("Result A", 1.0) + }, 0.0)), + new IllustrationPointTreeNode(new TestFaultTreeIllustrationPoint()) + }); + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + illustrationPointNode + } + }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), Enumerable.Empty(), illustrationPoints) + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPointResults( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingIllustrationPointResultsWithNonDistinctNamesInChildren_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + + var illustrationPointNode = new IllustrationPointTreeNode(new FaultTreeIllustrationPoint("Point A", 0.5, Enumerable.Empty(), CombinationType.And)); + illustrationPointNode.SetChildren(new[] + { + new IllustrationPointTreeNode(new TestSubMechanismIllustrationPoint("Point B")), + new IllustrationPointTreeNode(new TestSubMechanismIllustrationPoint("Point B")) + }); + var illustrationPoints = new Dictionary + { + { + new WindDirectionClosingSituation(new WindDirection("N", 0.0), "closing A"), + illustrationPointNode + } + }; + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new GeneralResult(0.5, new TestWindDirection(), Enumerable.Empty(), illustrationPoints) + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); + calculatorFactory.Expect(cf => cf.CreateDikeHeightCalculator(testDataPath)).Return(dikeHeightCalculator); + calculatorFactory.Expect(cf => cf.CreateOvertoppingRateCalculator(testDataPath)).Return(overtoppingRateCalculator); + mockRepository.ReplayAll(); + + GrassCoverErosionInwardsCalculation calculation = GetValidCalculationWithCalculateIllustrationPointsSettings(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => new GrassCoverErosionInwardsCalculationService().Calculate(calculation, + assessmentSection, + failureMechanism.GeneralInput, + failureMechanism.Contribution, + validFile); + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, messages => + { + Tuple[] tupleArray = messages.ToArray(); + + string[] msgs = tupleArray.Select(tuple => tuple.Item1).ToArray(); + + Assert.AreEqual(8, msgs.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + overtoppingCalculator.OutputDirectory, + msgs[1]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctChildNames( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingCalculationDescription, + calculation.Name, + msgs[2]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + dikeHeightCalculator.OutputDirectory, + msgs[3]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.HbnCalculationDescription, + calculation.Name, + msgs[4]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationFinishedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + overtoppingRateCalculator.OutputDirectory, + msgs[5]); + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertCalculationNotConvergedMessage( + GrassCoverErosionInwardsCalculationServiceTestHelper.OvertoppingRateCalculationDescription, + calculation.Name, + msgs[6]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[7]); + }); + + Assert.IsNotNull(calculation.Output); + Assert.IsFalse(calculation.Output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(calculation.Output.OvertoppingRateOutput.HasGeneralResult); + } + + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_ValidInputButOvertoppingRateIllustrationPointResultsOfIncorrectType_GeneralResultNotSetAndLogsWarning() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository, + validFile); + var overtoppingCalculator = new TestOvertoppingCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var dikeHeightCalculator = new TestHydraulicLoadsCalculator + { + IllustrationPointsResult = new TestGeneralResult() + }; + var overtoppingRateCalculator = new TestHydraulicLoadsCalculator + { IllustrationPointsResult = TestGeneralResult.CreateGeneralResultWithSubMechanismIllustrationPoints() }; var calculatorFactory = mockRepository.StrictMock(); @@ -2248,7 +2860,7 @@ } [Test] - public void Calculate_ValidInputButDikeHeightIllustrationPointResultsInvalid_GeneralResultNotSetAndLogsWarning() + public void Calculate_ValidInputButDikeHeightIllustrationPointResultsOfIncorrectType_GeneralResultNotSetAndLogsWarning() { // Setup GrassCoverErosionInwardsFailureMechanism failureMechanism = CreateGrassCoverErosionInwardsFailureMechanism(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil.Test/GrassCoverErosionInwardsCalculationServiceTestHelperTest.cs =================================================================== diff -u -re7d2fa8bebceab18b508f57c7a67baff37c2b9b9 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil.Test/GrassCoverErosionInwardsCalculationServiceTestHelperTest.cs (.../GrassCoverErosionInwardsCalculationServiceTestHelperTest.cs) (revision e7d2fa8bebceab18b508f57c7a67baff37c2b9b9) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil.Test/GrassCoverErosionInwardsCalculationServiceTestHelperTest.cs (.../GrassCoverErosionInwardsCalculationServiceTestHelperTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -182,6 +182,208 @@ } [Test] + [TestCase("description", "output")] + [TestCase("", null)] + [TestCase(null, "")] + public void AssertGeneralResultNonDistinctStochasts_ForDifferentParametersAndEqualMessage_DoesNotThrow( + string description, string name) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctStochasts( + description, + name, + $"Fout bij het uitlezen van de {description} illustratiepunten voor berekening {name}: " + + "Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen."); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.")] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslage")] + [TestCase("")] + [TestCase(null)] + public void AssertGeneralResultNonDistinctStochasts_NotEqualMessage_ThrowsAssertionException( + string message) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctStochasts( + string.Empty, + string.Empty, + message); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase("description", "output")] + [TestCase("", null)] + [TestCase(null, "")] + public void AssertGeneralResultNonDistinctIllustrationPoints_ForDifferentParametersAndEqualMessage_DoesNotThrow( + string description, string name) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPoints( + description, + name, + $"Fout bij het uitlezen van de {description} illustratiepunten voor berekening {name}: " + + "Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslagen."); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslagen.")] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslage")] + [TestCase("")] + [TestCase(null)] + public void AssertGeneralResultNonDistinctIllustrationPoints_NotEqualMessage_ThrowsAssertionException( + string message) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPoints( + string.Empty, + string.Empty, + message); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase("description", "output")] + [TestCase("", null)] + [TestCase(null, "")] + public void AssertGeneralResultNonDistinctIllustrationPointResults_ForDifferentParametersAndEqualMessage_DoesNotThrow( + string description, string name) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPointResults( + description, + name, + $"Fout bij het uitlezen van de {description} illustratiepunten voor berekening {name}: " + + "Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen."); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.")] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslage")] + [TestCase("")] + [TestCase(null)] + public void AssertGeneralResultNonDistinctIllustrationPointResults_NotEqualMessage_ThrowsAssertionException( + string message) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctIllustrationPointResults( + string.Empty, + string.Empty, + message); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase("description", "output")] + [TestCase("", null)] + [TestCase(null, "")] + public void AssertGeneralResultIncorrectTopLevelStochasts_ForDifferentParametersAndEqualMessage_DoesNotThrow( + string description, string name) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultIncorrectTopLevelStochasts( + description, + name, + $"Fout bij het uitlezen van de {description} illustratiepunten voor berekening {name}: " + + "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. " + + "Het uitlezen van illustratiepunten wordt overgeslagen."); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. Het uitlezen van illustratiepunten wordt overgeslagen.")] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. Het uitlezen van illustratiepunten wordt overgeslage")] + [TestCase("")] + [TestCase(null)] + public void AssertGeneralResultIncorrectTopLevelStochasts_NotEqualMessage_ThrowsAssertionException( + string message) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultIncorrectTopLevelStochasts( + string.Empty, + string.Empty, + message); + + // Assert + Assert.Throws(test); + } + + [Test] + [TestCase("description", "output")] + [TestCase("", null)] + [TestCase(null, "")] + public void AssertGeneralResultNonDistinctChildNames_ForDifferentParametersAndEqualMessage_DoesNotThrow( + string description, string name) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctChildNames( + description, + name, + $"Fout bij het uitlezen van de {description} illustratiepunten voor berekening {name}: " + + "Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen."); + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.")] + [TestCase("out bij het uitlezen van de illustratiepunten voor berekening : " + + "Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslage")] + [TestCase("")] + [TestCase(null)] + public void AssertGeneralResultNonDistinctChildNames_NotEqualMessage_ThrowsAssertionException( + string message) + { + // Call + TestDelegate test = () => + GrassCoverErosionInwardsCalculationServiceTestHelper.AssertGeneralResultNonDistinctChildNames( + string.Empty, + string.Empty, + message); + + // Assert + Assert.Throws(test); + } + + [Test] public void AssertGeneralResultNotSetMessage_EqualMessage_DoesNotThrow() { // Call Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil/GrassCoverErosionInwardsCalculationServiceTestHelper.cs =================================================================== diff -u -re7d2fa8bebceab18b508f57c7a67baff37c2b9b9 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil/GrassCoverErosionInwardsCalculationServiceTestHelper.cs (.../GrassCoverErosionInwardsCalculationServiceTestHelper.cs) (revision e7d2fa8bebceab18b508f57c7a67baff37c2b9b9) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.TestUtil/GrassCoverErosionInwardsCalculationServiceTestHelper.cs (.../GrassCoverErosionInwardsCalculationServiceTestHelper.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -54,5 +54,37 @@ { Assert.AreEqual("Het uitlezen van illustratiepunten is mislukt.", actual); } + + public static void AssertGeneralResultNonDistinctStochasts(string calculationDescription, string calculationName, string actual) + { + Assert.AreEqual($"Fout bij het uitlezen van de {calculationDescription} illustratiepunten voor berekening {calculationName}: " + + "Een of meerdere stochasten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.", actual); + } + + public static void AssertGeneralResultNonDistinctIllustrationPoints(string calculationDescription, string calculationName, string actual) + { + Assert.AreEqual($"Fout bij het uitlezen van de {calculationDescription} illustratiepunten voor berekening {calculationName}: " + + "Een of meerdere illustratiepunten hebben dezelfde sluitscenario en windrichting. Het uitlezen van illustratiepunten wordt overgeslagen.", actual); + } + + public static void AssertGeneralResultNonDistinctIllustrationPointResults(string calculationDescription, string calculationName, string actual) + { + Assert.AreEqual($"Fout bij het uitlezen van de {calculationDescription} illustratiepunten voor berekening {calculationName}: " + + "Een of meerdere resultaten hebben dezelfde naam. Het uitlezen van illustratiepunten wordt overgeslagen.", actual); + } + + public static void AssertGeneralResultIncorrectTopLevelStochasts(string calculationDescription, string calculationName, string actual) + { + Assert.AreEqual($"Fout bij het uitlezen van de {calculationDescription} illustratiepunten voor berekening {calculationName}: " + + "De stochasten van een illustratiepunt bevatten niet dezelfde stochasten als de illustratiepunten die het punt bevat. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", actual); + } + + public static void AssertGeneralResultNonDistinctChildNames(string calculationDescription, string calculationName, string actual) + { + Assert.AreEqual($"Fout bij het uitlezen van de {calculationDescription} illustratiepunten voor berekening {calculationName}: " + + "Een of meerdere illustratiepunten bevatten illustratiepunten met dezelfde naam. " + + "Het uitlezen van illustratiepunten wordt overgeslagen.", actual); + } } } \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/FaultTreeIllustrationPoint.cs =================================================================== diff -u -rf9a4756925eb517d1a95079428b9a2011c525733 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision f9a4756925eb517d1a95079428b9a2011c525733) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -21,6 +21,8 @@ using System; using System.Collections.Generic; +using Core.Common.Utils.Extensions; +using Ringtoets.Common.Data.Properties; namespace Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints { @@ -52,6 +54,8 @@ throw new ArgumentNullException(nameof(stochasts)); } + ValidateStochasts(stochasts); + Beta = beta; CombinationType = combinationType; Name = name; @@ -78,5 +82,14 @@ /// obtain a result for the fault tree illustration point. /// public CombinationType CombinationType { get; } + + private static void ValidateStochasts(IEnumerable stochasts) + { + bool hasNonDistinctStochasts = stochasts.AnyNonDistinct(s => s.Name); + if (hasNonDistinctStochasts) + { + throw new ArgumentException(string.Format(Resources.GeneralResult_Imported_non_unique_stochasts)); + } + } } } \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj =================================================================== diff -u -r45762d43270b997ca89d8f8ec73f7b895b52bd6a -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 45762d43270b997ca89d8f8ec73f7b895b52bd6a) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -166,6 +166,11 @@ Core.Common.Utils False + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + False + {b69d5b6c-6e14-4fa9-9ebc-8f97678cdb70} Ringtoets.HydraRing.IO Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs =================================================================== diff -u -r2faf760ac8a46319780e2669e68d59b45b71ba99 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs (.../IllustrationPointsParserTest.cs) (revision 2faf760ac8a46319780e2669e68d59b45b71ba99) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Parsers/IllustrationPoints/IllustrationPointsParserTest.cs (.../IllustrationPointsParserTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -195,9 +195,9 @@ Assert.NotNull(generalResult); Assert.NotNull(generalResult.GoverningWindDirection); Assert.AreEqual(30, generalResult.GoverningWindDirection.Angle); - Assert.AreEqual(" 30,0", generalResult.GoverningWindDirection.Name); - Assert.AreEqual(-0.122527, generalResult.Beta); - Assert.AreEqual(46, generalResult.Stochasts.Count()); + Assert.AreEqual(" 30", generalResult.GoverningWindDirection.Name); + Assert.AreEqual(-3.74187, generalResult.Beta); + Assert.AreEqual(44, generalResult.Stochasts.Count()); Dictionary illustrationPointNodes = generalResult.IllustrationPoints; Assert.AreEqual(12, illustrationPointNodes.Count); @@ -225,27 +225,27 @@ Assert.AreEqual(12, subMechanisms.Count); SubMechanismIllustrationPoint subMechanismIllustrationPoint = subMechanisms.First(); - Assert.AreEqual("Structure 2017 Z12", subMechanismIllustrationPoint.Name); + Assert.AreEqual("Bezwijken kunstwerk als gevolg van erosie bodem", subMechanismIllustrationPoint.Name); Assert.AreEqual(-7.94268, subMechanismIllustrationPoint.Beta); Assert.AreEqual(new[] { - Tuple.Create("Faalkans kunstwerk gegeven erosie bodem", -1.0, 4383.0, -7.94268) + Tuple.Create("Faalkans gegeven erosie bodem", -1.0, 4383.0, -7.94268) }, subMechanismIllustrationPoint.Stochasts.Select(s => Tuple.Create(s.Name, s.Alpha, s.Duration, s.Realization))); CollectionAssert.IsEmpty(subMechanismIllustrationPoint.Results); FaultTreeIllustrationPoint faultTreeIllustrationPoint = faultTrees.First(); - Assert.AreEqual("Structure 2017 Z12", subMechanismIllustrationPoint.Name); - Assert.AreEqual(2.23881, faultTreeIllustrationPoint.Beta); + Assert.AreEqual("Bezwijken kunstwerk als gevolg van erosie bodem", subMechanismIllustrationPoint.Name); + Assert.AreEqual(0.508398, faultTreeIllustrationPoint.Beta); Assert.AreEqual(CombinationType.Or, faultTreeIllustrationPoint.CombinationType); - Assert.AreEqual(46, faultTreeIllustrationPoint.Stochasts.Count()); + Assert.AreEqual(44, faultTreeIllustrationPoint.Stochasts.Count()); Assert.AreEqual(new[] { - Tuple.Create("Kerende hoogte van het kunstwerk", 0.0, 4383.0), + Tuple.Create("Kerende hoogte", 0.0, 4383.0), Tuple.Create("Modelfactor voor onvolkomen stroming", 0.0, 4383.0), - Tuple.Create("Drempelhoogte niet gesloten kering of Hoogte van de onderkant van de wand/drempel", 0.0, 4383.0), - Tuple.Create("Afvoercoefficient", -0.000743268, 4383.0), - Tuple.Create("Doorstroomoppervlak van doorstroomopeningen", -1.48258e-05, 4383.0), - Tuple.Create("Constructieve sterkte lineair belastingmodel stabiliteit", 0.011086, 4383.0) + Tuple.Create("Drempelhoogte", 0.0, 4383.0), + Tuple.Create("Afvoercoefficient", -3.91812E-07, 4383.0), + Tuple.Create("Doorstroomoppervlak", 3.93695E-08, 4383.0), + Tuple.Create("Lineaire belastingschematisering constructieve sterkte", 0.214064, 4383.0) }, faultTreeIllustrationPoint.Stochasts.Take(6).Select(s => Tuple.Create(s.Name, s.Alpha, s.Duration))); } Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/ValidStructuresStabilityOutputSection1/1-output.sqlite =================================================================== diff -u -rc4f75aa39431df092fc41bd13c1bd66c52b9e36e -r57b198a3f80256e02b871d8de11c05d9f2dcf311 Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/test-data/Parsers/IllustrationPointsParser/ValidStructuresStabilityOutputSection1/2-output.sqlite =================================================================== diff -u -rb75888ac4a86ce24369ba0dad93cfe5bcd3fc794 -r57b198a3f80256e02b871d8de11c05d9f2dcf311 Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs =================================================================== diff -u -rfc1d79e8dac002800fff0d485a63f4b400f8ab2b -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision fc1d79e8dac002800fff0d485a63f4b400f8ab2b) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -29,7 +29,7 @@ public class TestSubMechanismIllustrationPointTest { [Test] - public void Constructor_ExpectedValues() + public void DefaultConstructor_ExpectedValues() { // Call var illustrationPoint = new TestSubMechanismIllustrationPoint(); @@ -41,5 +41,19 @@ CollectionAssert.IsEmpty(illustrationPoint.Results); Assert.AreEqual(1, illustrationPoint.Beta); } + + [Test] + public void Constructor_WithName_ExpectedValues() + { + // Call + var illustrationPoint = new TestSubMechanismIllustrationPoint("Point name"); + + // Assert + Assert.IsInstanceOf(illustrationPoint); + Assert.AreEqual("Point name", illustrationPoint.Name); + CollectionAssert.IsEmpty(illustrationPoint.Stochasts); + CollectionAssert.IsEmpty(illustrationPoint.Results); + Assert.AreEqual(1, illustrationPoint.Beta); + } } } \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs =================================================================== diff -u -rfc1d79e8dac002800fff0d485a63f4b400f8ab2b -r57b198a3f80256e02b871d8de11c05d9f2dcf311 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs (.../TestSubMechanismIllustrationPoint.cs) (revision fc1d79e8dac002800fff0d485a63f4b400f8ab2b) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs (.../TestSubMechanismIllustrationPoint.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) @@ -35,5 +35,13 @@ public TestSubMechanismIllustrationPoint() : base("Illustration point", Enumerable.Empty(), Enumerable.Empty(), 1) {} + + /// + /// Creates a new instance of . + /// + /// The name of the illustration point + public TestSubMechanismIllustrationPoint(string name) + : base(name, Enumerable.Empty(), + Enumerable.Empty(), 1) {} } } \ No newline at end of file