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