Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs =================================================================== diff -u -r36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1 -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs (.../RingtoetsGraphNodeFactory.cs) (revision 36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsGraphNodeFactory.cs (.../RingtoetsGraphNodeFactory.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -25,7 +25,12 @@ using System.Linq; using System.Text; using System.Xml; +using Core.Common.Base.Data; +using Core.Common.Utils; using Core.Components.PointedTree.Data; +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.Properties; namespace Ringtoets.Common.Forms.Factories { @@ -41,76 +46,85 @@ }; /// - /// Create with default styling for an end node. + /// Creates a new based on the provided input. /// - /// The title to set for this node. - /// The content to set for this node. - /// The created . - /// Thrown when any input parameter is null. - public static GraphNode CreateEndGraphNode(string title, string content) + /// The illustration point. + /// The child nodes of the illustration point. + /// The newly created . + /// Thrown when any input parameter is null. + /// Thrown when + /// is not of type or . + public static GraphNode CreateGraphNode(IllustrationPointBase illustrationPoint, IEnumerable childNodes) { - if (title == null) + if (illustrationPoint == null) { - throw new ArgumentNullException(nameof(title)); + throw new ArgumentNullException(nameof(illustrationPoint)); } - if (content == null) + if (childNodes == null) { - throw new ArgumentNullException(nameof(content)); + throw new ArgumentNullException(nameof(childNodes)); } - return new GraphNode(GetGraphNodeContentXml(content, title), - new GraphNode[0], - true, - new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1)); + var subMechanismIllustrationPoint = illustrationPoint as SubMechanismIllustrationPoint; + if (subMechanismIllustrationPoint != null) + { + return CreateEndGraphNode(illustrationPoint.Name, + CreateGraphNodeContent(illustrationPoint.Beta)); + } + + var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint; + if (faultTreeIllustrationPoint != null) + { + return CreateFaultTreeGraphNode(faultTreeIllustrationPoint, + childNodes); + } + + throw new NotSupportedException($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); } /// - /// Create with default styling for a composite node. + /// Creates a new instance of , based on the properties of . /// - /// The title to set for this node. - /// The content to set for this node. - /// The child nodes of this node. + /// The to base the + /// to create on. + /// The child graph nodes of the to create. /// The created . - /// Thrown when any input parameter is null. - public static GraphNode CreateCompositeGraphNode(string title, string content, IEnumerable childNodes) + private static GraphNode CreateFaultTreeGraphNode(FaultTreeIllustrationPoint illustrationPoint, + IEnumerable childNodes) { - if (title == null) - { - throw new ArgumentNullException(nameof(title)); - } - if (content == null) - { - throw new ArgumentNullException(nameof(content)); - } - if (childNodes == null) - { - throw new ArgumentNullException(nameof(childNodes)); - } + string childRelationTitle = illustrationPoint.CombinationType == CombinationType.And + ? Resources.GraphNode_CombinationType_And + : Resources.GraphNode_CombinationType_Or; + GraphNode connectionGraphNode = CreateConnectingGraphNode(childRelationTitle, childNodes); + return CreateCompositeGraphNode( + illustrationPoint.Name, + CreateGraphNodeContent(illustrationPoint.Beta), + new[] + { + connectionGraphNode + }); + } + + private static GraphNode CreateEndGraphNode(string title, string content) + { return new GraphNode(GetGraphNodeContentXml(content, title), + new GraphNode[0], + true, + new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1)); + } + + private static GraphNode CreateCompositeGraphNode(string title, string content, IEnumerable childNodes) + { + return new GraphNode(GetGraphNodeContentXml(content, title), childNodes.ToArray(), true, new GraphNodeStyle(GraphNodeShape.Rectangle, Color.LightGray, Color.Black, 1)); } - /// - /// Create with default styling for a connecting node. - /// - /// The title to set for this node. - /// The child nodes of this node. - /// The created . - /// Thrown when any input parameter is null. - public static GraphNode CreateConnectingGraphNode(string title, IEnumerable childNodes) + private static GraphNode CreateConnectingGraphNode(string title, IEnumerable childNodes) { - if (title == null) - { - throw new ArgumentNullException(nameof(title)); - } - if (childNodes == null) - { - throw new ArgumentNullException(nameof(childNodes)); - } - return new GraphNode(GetGraphNodeContentXml(title), childNodes.ToArray(), false, @@ -142,5 +156,12 @@ return builder.ToString(); } + + private static string CreateGraphNodeContent(RoundedDouble beta) + { + return string.Format(Resources.GraphNodeConverter_GraphNodeContent_Beta_0_Probability_1, + beta, + ProbabilityFormattingHelper.Format(StatisticsConverter.ReliabilityToProbability(beta))); + } } } \ No newline at end of file Fisheye: Tag 09657885dd6a95975a8e117f8b8c570cd84a2523 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/GraphNodeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r9820d06750b3667c39aae2cea1262256f434db5e -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 9820d06750b3667c39aae2cea1262256f434db5e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -65,7 +65,6 @@ - @@ -237,9 +236,6 @@ ScenarioSelectionControl.cs - - IllustrationPointsFaultTreeControl.cs - GeneralResultFaultTreeIllustrationPointView.cs Designer Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs =================================================================== diff -u -r244dd8357f6de439ff2364fa675a9e128da84b5c -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs (.../IllustrationPointsFaultTreeControl.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs (.../IllustrationPointsFaultTreeControl.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -26,6 +26,7 @@ using Core.Common.Controls.Views; using Core.Components.PointedTree.Data; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Forms.Factories; namespace Ringtoets.Common.Forms.Views { @@ -51,6 +52,8 @@ /// /// Gets or sets the data of the control. /// + /// Thrown when or any of its children + /// is not of type or . public TopLevelFaultTreeIllustrationPoint Data { get @@ -62,7 +65,7 @@ drawnNodes.Clear(); data = value; - + pointedTreeGraphControl.Data = data != null ? RegisterNode(data.FaultTreeNodeRoot) : null; @@ -77,11 +80,19 @@ } } + /// + /// Creates a new based on the and registers + /// the and combination. + /// + /// The node to base the on. + /// The newly created . + /// Thrown when or any of its children + /// is not of type or . private GraphNode RegisterNode(IllustrationPointNode node) { List childNodes = node.Children.Select(RegisterNode).ToList(); - GraphNode graphNode = CreateGraphNode(node.Data, childNodes); + GraphNode graphNode = RingtoetsGraphNodeFactory.CreateGraphNode(node.Data, childNodes); drawnNodes.Add(new DrawnIllustrationPointNode { IllustrationPointNode = node, @@ -91,24 +102,6 @@ return graphNode; } - private static GraphNode CreateGraphNode(IllustrationPointBase illustrationPoint, IEnumerable childNodes) - { - var subMechanismIllustrationPoint = illustrationPoint as SubMechanismIllustrationPoint; - if (subMechanismIllustrationPoint != null) - { - return GraphNodeConverter.ConvertSubMechanismIllustrationPoint(subMechanismIllustrationPoint); - } - - var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint; - if (faultTreeIllustrationPoint != null) - { - return GraphNodeConverter.ConvertFaultTreeIllustrationPoint(faultTreeIllustrationPoint, - childNodes); - } - - return null; - } - private void InitializeEventHandlers() { pointedTreeGraphControl.SelectionChanged += FaultTreeIllustrationPointsControlOnSelectionChanged; Fisheye: Tag 09657885dd6a95975a8e117f8b8c570cd84a2523 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs =================================================================== diff -u -r36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1 -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs (.../RingtoetsGraphNodeFactoryTest.cs) (revision 36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Factories/RingtoetsGraphNodeFactoryTest.cs (.../RingtoetsGraphNodeFactoryTest.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -20,184 +20,183 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using Core.Common.Utils; using Core.Components.PointedTree.Data; using NUnit.Framework; +using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.Factories; +using Ringtoets.Common.Forms.Helpers; namespace Ringtoets.Common.Forms.Test.Factories { [TestFixture] public class RingtoetsGraphNodeFactoryTest { [Test] - public void CreateEndGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling() + public void CreateGraphNode_IllustrationPointNull_ThrowsArgumentNullException() { // Setup - const string title = "title"; - const string content = "content"; // Call - GraphNode node = RingtoetsGraphNodeFactory.CreateEndGraphNode(title, content); + TestDelegate test = () => RingtoetsGraphNodeFactory.CreateGraphNode(null, Enumerable.Empty()); // Assert - string expectedContent = $"{title}{Environment.NewLine}{content}"; - Assert.AreEqual(expectedContent, node.Content); - Assert.IsTrue(node.IsSelectable); - - var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1); - AssertEqualStyle(expectedStyle, node.Style); - - CollectionAssert.IsEmpty(node.ChildNodes); + var exception = Assert.Throws(test); + Assert.AreEqual("illustrationPoint", exception.ParamName); } [Test] - public void CreateEndGraphNode_TitleNull_ThrowsArgumentNullException() + public void CreateGraphNode_WithSubMechanismIllustrationPointButChildrenNull_ThrowsArgumentNullException() { + // Setup + var illustrationPoint = new SubMechanismIllustrationPoint( + "Illustration Point", + new Random(31).NextRoundedDouble(), + Enumerable.Empty(), + Enumerable.Empty()); + // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateEndGraphNode(null, "content"); + TestDelegate test = () => RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, null); // Assert var exception = Assert.Throws(test); - Assert.AreEqual("title", exception.ParamName); + Assert.AreEqual("childNodes", exception.ParamName); } [Test] - public void CreateEndGraphNode_ContentNull_ThrowsArgumentNullException() + public void CreateGraphNode_WithSubMechanismIllustrationPointEmptyChildren_ReturnsGraphNodeWithExpectedStyling() { + // Setup + var illustrationPoint = new SubMechanismIllustrationPoint( + "Illustration Point", + new Random(31).NextRoundedDouble(), + Enumerable.Empty(), + Enumerable.Empty()); + // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateEndGraphNode("title", null); + GraphNode graphNode = RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, new[] + { + CreateTestGraphNode() + }); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("content", exception.ParamName); + Assert.AreEqual(CreateExpectedGraphNodeContent(illustrationPoint.Name, illustrationPoint.Beta), graphNode.Content); + Assert.IsTrue(graphNode.IsSelectable); + CollectionAssert.IsEmpty(graphNode.ChildNodes); + + var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.SkyBlue, Color.Black, 1); + AssertEqualStyle(expectedStyle, graphNode.Style); } [Test] - public void CreateCompositeGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling() + public void CreateGraphNode_FaultTreeIllustrationPointNodeDataWithoutChildren_ReturnsExpected() { // Setup - const string title = "compositeTitle"; - const string content = "compositeContent"; + var random = new Random(31); + var illustrationPoint = new FaultTreeIllustrationPoint( + "Illustration Point", + random.NextRoundedDouble(), + Enumerable.Empty(), + random.NextEnumValue()); - GraphNode childNode = new TestGraphNode(); - // Call - GraphNode node = RingtoetsGraphNodeFactory.CreateCompositeGraphNode(title, content, new[] - { - childNode - }); + GraphNode graphNode = RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, + Enumerable.Empty()); // Assert - string expectedContent = $"{title}{Environment.NewLine}{content}"; - Assert.AreEqual(expectedContent, node.Content); - Assert.IsTrue(node.IsSelectable); + Assert.AreEqual(CreateExpectedGraphNodeContent(illustrationPoint.Name, illustrationPoint.Beta), graphNode.Content); + Assert.IsTrue(graphNode.IsSelectable); var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.LightGray, Color.Black, 1); - AssertEqualStyle(expectedStyle, node.Style); + AssertEqualStyle(expectedStyle, graphNode.Style); - Assert.AreEqual(1, node.ChildNodes.Count()); - Assert.AreSame(childNode, node.ChildNodes.First()); + Assert.AreEqual(1, graphNode.ChildNodes.Count()); + GraphNode connectingNode = graphNode.ChildNodes.First(); + AssertGraphConnectingNode(CreateExpectedGraphConnectingNodeContent(illustrationPoint.CombinationType), connectingNode); + CollectionAssert.IsEmpty(connectingNode.ChildNodes); } [Test] - public void CreateCompositeGraphNode_TitleNull_ThrowsArgumentNullException() + public void CreateGraphNode_FaultTreeIllustrationPointNodeDataWithChildren_ReturnsExpected() { - // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateCompositeGraphNode(null, - "content", - new[] - { - new TestGraphNode() - }); + // Setup + var random = new Random(31); + var illustrationPoint = new FaultTreeIllustrationPoint( + "Illustration Point", + random.NextRoundedDouble(), + Enumerable.Empty(), + random.NextEnumValue()); - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("title", exception.ParamName); - } + IEnumerable childGraphNodes = new[] + { + CreateTestGraphNode() + }; - [Test] - public void CreateCompositeGraphNode_ContentNull_ThrowsArgumentNullException() - { // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateCompositeGraphNode("title", - null, - new[] - { - new TestGraphNode() - }); + GraphNode graphNode = RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, + childGraphNodes); // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("content", exception.ParamName); + Assert.AreEqual(CreateExpectedGraphNodeContent(illustrationPoint.Name, illustrationPoint.Beta), graphNode.Content); + Assert.IsTrue(graphNode.IsSelectable); + + var expectedStyle = new GraphNodeStyle(GraphNodeShape.Rectangle, Color.LightGray, Color.Black, 1); + AssertEqualStyle(expectedStyle, graphNode.Style); + + Assert.AreEqual(1, graphNode.ChildNodes.Count()); + GraphNode connectingNode = graphNode.ChildNodes.First(); + AssertGraphConnectingNode(CreateExpectedGraphConnectingNodeContent(illustrationPoint.CombinationType), connectingNode); + CollectionAssert.AreEqual(childGraphNodes, connectingNode.ChildNodes); } [Test] - public void CreateCompositeGraphNode_ChildNodesNull_ThrowsArgumentNullException() + public void CreateGraphNode_WithFaultTreeIllustrationPointButChildrenNull_ThrowsArgumentNullException() { + // Setup + var illustrationPoint = new TestFaultTreeIllustrationPoint(); + // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateCompositeGraphNode("title", - "content", - null); + TestDelegate test = () => RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, null); // Assert var exception = Assert.Throws(test); Assert.AreEqual("childNodes", exception.ParamName); } [Test] - public void CreateConnectingGraphNode_ValidInput_ReturnsGraphNodeWithExpectedStyling() + public void CreateGraphNode_WithNotSupportedIllustrationPoint_ThrowsNotSupportedException() { // Setup - const string title = "title"; - GraphNode childNode = new TestGraphNode(); + var illustrationPoint = new TestIllustrationPoint(); // Call - GraphNode node = RingtoetsGraphNodeFactory.CreateConnectingGraphNode(title, new[] + TestDelegate test = () => RingtoetsGraphNodeFactory.CreateGraphNode(illustrationPoint, new[] { - childNode + CreateTestGraphNode() }); // Assert - string expectedContent = $"{title}"; - Assert.AreEqual(expectedContent, node.Content); - Assert.IsFalse(node.IsSelectable); - - var expectedStyle = new GraphNodeStyle(GraphNodeShape.None, Color.BlanchedAlmond, Color.Black, 1); - AssertEqualStyle(expectedStyle, node.Style); - - Assert.AreEqual(1, node.ChildNodes.Count()); - Assert.AreSame(childNode, node.ChildNodes.First()); + var exception = Assert.Throws(test); + Assert.AreEqual($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}", + exception.Message); } - [Test] - public void CreateConnectingGraphNode_TitleNull_ThrowsArgumentNullException() + private static void AssertGraphConnectingNode(string expectedContent, GraphNode actualNode) { - // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateConnectingGraphNode(null, - new[] - { - new TestGraphNode() - }); + Assert.IsFalse(actualNode.IsSelectable); + Assert.AreEqual(expectedContent, actualNode.Content); - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("title", exception.ParamName); + var expectedConnectingStyle = new GraphNodeStyle(GraphNodeShape.None, Color.BlanchedAlmond, Color.Black, 1); + AssertEqualStyle(expectedConnectingStyle, actualNode.Style); } - [Test] - public void CreateConnectingGraphNode_ChildNodesNull_ThrowsArgumentNullException() - { - // Call - TestDelegate test = () => RingtoetsGraphNodeFactory.CreateConnectingGraphNode("title", - null); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("childNodes", exception.ParamName); - } - private static void AssertEqualStyle(GraphNodeStyle expected, GraphNodeStyle actual) { Assert.AreEqual(expected.FillColor, actual.FillColor); @@ -206,14 +205,33 @@ Assert.AreEqual(expected.Shape, actual.Shape); } - private class TestGraphNode : GraphNode + private static GraphNode CreateTestGraphNode() { - public TestGraphNode() : base("content", new GraphNode[0], false, new TestGraphNodeStyle()) {} + return new GraphNode("content", new GraphNode[0], false, CreateTestGraphNodeStyle()); } - private class TestGraphNodeStyle : GraphNodeStyle + private static GraphNodeStyle CreateTestGraphNodeStyle() { - public TestGraphNodeStyle() : base(GraphNodeShape.None, Color.Empty, Color.Empty, 1) {} + return new GraphNodeStyle(GraphNodeShape.None, Color.Empty, Color.Empty, 1); } + + private static string CreateExpectedGraphNodeContent(string name, RoundedDouble beta) + { + RoundedDouble roundedBeta = beta.ToPrecision(5); + string probability = ProbabilityFormattingHelper.Format(StatisticsConverter.ReliabilityToProbability(beta)); + + return $"{name}{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Beta = {roundedBeta}{Environment.NewLine}" + + $"Pf = {probability}"; + } + + private static string CreateExpectedGraphConnectingNodeContent(CombinationType combinationType) + { + string name = combinationType == CombinationType.And + ? "En" + : "Of"; + return $"{name}"; + } } } \ No newline at end of file Fisheye: Tag 09657885dd6a95975a8e117f8b8c570cd84a2523 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/GraphNodeConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1 -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 36d3f041dd6f35e62c53b3d1b95bcd4171aa38b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -87,7 +87,6 @@ - Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs =================================================================== diff -u -r3b6e16ea6eaca91a709fbfcb565ab392d7805f75 -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs (.../IllustrationPointsFaultTreeControlTest.cs) (revision 3b6e16ea6eaca91a709fbfcb565ab392d7805f75) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsFaultTreeControlTest.cs (.../IllustrationPointsFaultTreeControlTest.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using System.Threading; using System.Windows.Forms; @@ -93,6 +94,55 @@ } [Test] + public void GivenControl_WhenDataSetToInvalidIllustrationPointType_ThenThrowsNotSupportedException() + { + // Given + using (var control = new IllustrationPointsFaultTreeControl()) + { + var notSupported = new TopLevelFaultTreeIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + "closing situation", + new IllustrationPointNode(new TestIllustrationPoint())); + + // When + TestDelegate test = () => control.Data = notSupported; + + // Then + var exception = Assert.Throws(test); + Assert.AreEqual($"IllustrationPointNode of type {nameof(TestIllustrationPoint)} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}", exception.Message); + } + } + + [Test] + public void GivenControl_WhenDataSetWithInvalidIllustrationPointChildType_ThenThrowsNotSupportedException() + { + // Given + using (var control = new IllustrationPointsFaultTreeControl()) + { + var rootNode = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); + rootNode.SetChildren(new[] + { + new IllustrationPointNode(new TestIllustrationPoint()), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint()) + }); + + var topLevelFaultTreeIllustrationPoint = new TopLevelFaultTreeIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + "closing situation", + rootNode); + + // When + TestDelegate test = () => control.Data = topLevelFaultTreeIllustrationPoint; + + // Then + var exception = Assert.Throws(test); + Assert.AreEqual($"IllustrationPointNode of type {nameof(TestIllustrationPoint)} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}", exception.Message); + } + } + + [Test] public void GivenControlWithData_WhenVertexSelected_SelectionSetToCorrespondingIllustrationPointNodeSelectionChangedFired() { // Given Index: Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs =================================================================== diff -u -re919aacb7342da4be2675964c281d133f8dc4abb -r09657885dd6a95975a8e117f8b8c570cd84a2523 --- Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs (.../ShouldCloseViewWithCalculationDataTester.cs) (revision e919aacb7342da4be2675964c281d133f8dc4abb) +++ Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs (.../ShouldCloseViewWithCalculationDataTester.cs) (revision 09657885dd6a95975a8e117f8b8c570cd84a2523) @@ -36,6 +36,7 @@ /// /// Class for testing . /// + [TestFixture] [Apartment(ApartmentState.STA)] public abstract class ShouldCloseViewWithCalculationDataTester {