Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IllustrationPointProperties.cs =================================================================== diff -u -r390c486bb4cd693ae2f2eaf82a30efcb51480048 -r244dd8357f6de439ff2364fa675a9e128da84b5c --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IllustrationPointProperties.cs (.../IllustrationPointProperties.cs) (revision 390c486bb4cd693ae2f2eaf82a30efcb51480048) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IllustrationPointProperties.cs (.../IllustrationPointProperties.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) @@ -138,7 +138,8 @@ } // If type is not supported, throw exception (currently not possible, safeguard for future) - throw new NotSupportedException($"IllustrationPointNode of type {nameof(FaultTreeIllustrationPoint)} is not supported. Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); + throw new NotSupportedException($"IllustrationPointNode of type {illustrationPointNode.Data.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); } return points.ToArray(); } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs =================================================================== diff -u -r9820d06750b3667c39aae2cea1262256f434db5e -r244dd8357f6de439ff2364fa675a9e128da84b5c --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 9820d06750b3667c39aae2cea1262256f434db5e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) @@ -99,6 +99,12 @@ base.Dispose(disposing); } + /// + /// Updates the controls. + /// + /// Thrown when the top level fault tree illustration + /// contains an illustration point that is not of type + /// or . private void UpdateControls() { suspendAllEvents = true; @@ -140,12 +146,14 @@ private IEnumerable GetIllustrationPointControlItems() { - if (data == null) + GeneralResult generalResult = getGeneralResultFunc(); + + if (data == null || generalResult == null) { - return null; + return Enumerable.Empty(); } - return getGeneralResultFunc()?.TopLevelIllustrationPoints.Select(topLevelFaultTreeIllustrationPoint => + return generalResult.TopLevelIllustrationPoints.Select(topLevelFaultTreeIllustrationPoint => { IllustrationPointBase illustrationPoint = topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot.Data; @@ -157,6 +165,13 @@ }); } + /// + /// Returns the stochasts of the . + /// + /// The illustration point to get the stochasts from. + /// The stochasts. + /// Thrown when + /// is not of type or . private static IEnumerable GetStochasts(IllustrationPointBase illustrationPoint) { var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint; @@ -171,7 +186,8 @@ return subMechanismIllustrationPoint.Stochasts; } - return null; + throw new NotSupportedException($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " + + $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}"); } private void UpdateIllustrationPointsFaultTreeControl() @@ -191,6 +207,12 @@ ProvideIllustrationPointSelection(); } + /// + /// Sets the based on the selection of the . + /// + /// Thrown when the top level fault tree illustration + /// contains an illustration point that is not of type + /// or . private void ProvideIllustrationPointSelection() { var selection = illustrationPointsControl.Selection as IllustrationPointControlItem; Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs =================================================================== diff -u -rd7706775b2e3f09e8a2a7f965668cc9595ec3fa8 -r244dd8357f6de439ff2364fa675a9e128da84b5c --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs (.../IllustrationPointsFaultTreeControl.cs) (revision d7706775b2e3f09e8a2a7f965668cc9595ec3fa8) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsFaultTreeControl.cs (.../IllustrationPointsFaultTreeControl.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) @@ -59,11 +59,11 @@ } set { - data = value; - drawnNodes.Clear(); - pointedTreeGraphControl.Data = value != null + data = value; + + pointedTreeGraphControl.Data = data != null ? RegisterNode(data.FaultTreeNodeRoot) : null; } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs =================================================================== diff -u -r9820d06750b3667c39aae2cea1262256f434db5e -r244dd8357f6de439ff2364fa675a9e128da84b5c --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision 9820d06750b3667c39aae2cea1262256f434db5e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision 244dd8357f6de439ff2364fa675a9e128da84b5c) @@ -149,6 +149,27 @@ } [Test] + public void GivenViewWithGeneralResultFuncReturningNotSupportedIllustrationPoint_WhenSettingData_ThenThrowsNotSupportedException() + { + // Given + var data = new TestCalculation + { + Output = new object() + }; + + using (var view = new GeneralResultFaultTreeIllustrationPointView(GetGeneralResultWithTopLevelIllustrationPointsOfNotSupportedType)) + { + // When + TestDelegate test = () => view.Data = data; + + // 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 GivenDisposedViewWithDataSetAndGeneralResultFuncReturningData_WhenDataNotifiesObserver_ThenControlsNoLongerSynced() { // Given @@ -178,6 +199,19 @@ } } + private static GeneralResult GetGeneralResultWithTopLevelIllustrationPointsOfNotSupportedType() + { + return new GeneralResult(WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + new[] + { + new TopLevelFaultTreeIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + "Closing situation 2", + new IllustrationPointNode(new TestIllustrationPoint())) + }); + } + private static IllustrationPointsFaultTreeControl GetIllustrationPointsFaultTreeControl(GeneralResultFaultTreeIllustrationPointView view) { return TypeUtils.GetField(view, "illustrationPointsFaultTreeControl"); @@ -512,7 +546,7 @@ // Then IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - Assert.IsNull(illustrationPointsControl.Data); + CollectionAssert.IsEmpty(illustrationPointsControl.Data); IllustrationPointsFaultTreeControl illustrationPointsFaultTreeControl = GetIllustrationPointsFaultTreeControl(view); Assert.IsNull(illustrationPointsFaultTreeControl.Data); @@ -522,7 +556,7 @@ } [Test] - public void GivenViewWithGeneralResultFuncReturningNull_WhenSettingCalculationWithoutOutput_ThenControlsDataNull() + public void GivenViewWithGeneralResultFuncReturningNull_WhenSettingCalculationWithoutOutput_ThenControlsDataCleared() { // Given var mocks = new MockRepository(); @@ -537,7 +571,7 @@ // Then IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - Assert.IsNull(illustrationPointsControl.Data); + CollectionAssert.IsEmpty(illustrationPointsControl.Data); IllustrationPointsFaultTreeControl illustrationPointsFaultTreeControl = GetIllustrationPointsFaultTreeControl(view); Assert.IsNull(illustrationPointsFaultTreeControl.Data); @@ -547,7 +581,7 @@ } [Test] - public void GivenViewWithGeneralResultFuncReturningNull_WhenSettingCalculationWithoutGeneralResult_ThenIllustrationPointsControlDataSetNull() + public void GivenViewWithGeneralResultFuncReturningNull_WhenSettingCalculationWithoutGeneralResult_ThenIllustrationPointsControlDataCleared() { // Given var data = new TestCalculation @@ -562,7 +596,7 @@ // Then IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - Assert.IsNull(illustrationPointsControl.Data); + CollectionAssert.IsEmpty(illustrationPointsControl.Data); IllustrationPointsFaultTreeControl illustrationPointsFaultTreeControl = GetIllustrationPointsFaultTreeControl(view); Assert.IsNull(illustrationPointsFaultTreeControl.Data); @@ -632,7 +666,7 @@ // Precondition IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - Assert.IsNull(illustrationPointsControl.Data); + CollectionAssert.IsEmpty(illustrationPointsControl.Data); IllustrationPointsFaultTreeControl illustrationPointsFaultTreeControl = GetIllustrationPointsFaultTreeControl(view); Assert.IsNull(illustrationPointsFaultTreeControl.Data); @@ -694,7 +728,7 @@ data.NotifyObservers(); // Then - Assert.IsNull(illustrationPointsControl.Data); + CollectionAssert.IsEmpty(illustrationPointsControl.Data); Assert.IsNull(illustrationPointsFaultTreeControl.Data); } }