Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs =================================================================== diff -u -re928e5f9e5924c2e7d72ceb51dbb4fe143d2fea7 -ra9b29f48534f9e3e2ab82dce7b81cfe13df515e2 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision e928e5f9e5924c2e7d72ceb51dbb4fe143d2fea7) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/GeneralResultFaultTreeIllustrationPointView.cs (.../GeneralResultFaultTreeIllustrationPointView.cs) (revision a9b29f48534f9e3e2ab82dce7b81cfe13df515e2) @@ -119,15 +119,23 @@ { var selection = illustrationPointsFaultTreeControl.Selection as IllustrationPointNode; TopLevelFaultTreeIllustrationPoint topLevelFaultTreeIllustrationPoint = illustrationPointsFaultTreeControl.Data; + GeneralResult generalResult = getGeneralResultFunc(); - if (selection == null || topLevelFaultTreeIllustrationPoint == null) + if (selection == null || topLevelFaultTreeIllustrationPoint == null || generalResult == null) { return; } + bool areClosingSituationsSame = generalResult.TopLevelIllustrationPoints + .Select(point => point.ClosingSituation) + .Distinct() + .Count() < 2; + Selection = new IllustrationPointNodeContext(selection, topLevelFaultTreeIllustrationPoint.WindDirection.Name, - topLevelFaultTreeIllustrationPoint.ClosingSituation); + areClosingSituationsSame + ? string.Empty + : topLevelFaultTreeIllustrationPoint.ClosingSituation); OnSelectionChanged(); } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs =================================================================== diff -u -r57b198a3f80256e02b871d8de11c05d9f2dcf311 -ra9b29f48534f9e3e2ab82dce7b81cfe13df515e2 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision 57b198a3f80256e02b871d8de11c05d9f2dcf311) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/GeneralResultFaultTreeIllustrationPointViewTest.cs (.../GeneralResultFaultTreeIllustrationPointViewTest.cs) (revision a9b29f48534f9e3e2ab82dce7b81cfe13df515e2) @@ -282,6 +282,38 @@ }); } + private static GeneralResult GetGeneralResultWithTwoTopLevelIllustrationPointsWithChildren(bool sameClosingSituations) + { + var faultTreeNodeRootWithChildren = new IllustrationPointNode(new TestFaultTreeIllustrationPoint()); + faultTreeNodeRootWithChildren.SetChildren(new[] + { + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("SubMechanismIllustrationPoint 1")), + new IllustrationPointNode(new TestSubMechanismIllustrationPoint("SubMechanismIllustrationPoint 2")) + }); + + var topLevelFaultTreeIllustrationPoint1 = + new TopLevelFaultTreeIllustrationPoint( + new WindDirection("Wind direction 1", 1.0), + sameClosingSituations ? "same closing situation" : "first closing situation", + faultTreeNodeRootWithChildren); + + var topLevelFaultTreeIllustrationPoint2 = + new TopLevelFaultTreeIllustrationPoint( + new WindDirection("Wind direction 2", 2.0), + sameClosingSituations ? "same closing situation" : "second closing situation", + new IllustrationPointNode(new TestSubMechanismIllustrationPoint())); + + var generalResultFunc = new GeneralResult( + WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + new[] + { + topLevelFaultTreeIllustrationPoint1, + topLevelFaultTreeIllustrationPoint2 + }); + return generalResultFunc; + } + private static GeneralResult GetGeneralResultWithoutTopLevelIllustrationPoints() { return new GeneralResult( @@ -430,15 +462,17 @@ } [Test] - public void GivenFullyConfiguredView_WhenSelectingFaultTreeIllustrationPointInTree_ThenSelectionChangedAndPropagatedAccordingly() + [TestCase(true)] + [TestCase(false)] + public void GivenFullyConfiguredView_WhenSelectingFaultTreeIllustrationPointInTree_ThenSelectionChangedAndPropagatedAccordingly(bool sameClosingSituations) { // Given var mocks = new MockRepository(); var data = mocks.Stub(); mocks.ReplayAll(); - GeneralResult generalResultFunc = GetGeneralResultWithTwoTopLevelIllustrationPoints(); + GeneralResult generalResultFunc = GetGeneralResultWithTwoTopLevelIllustrationPointsWithChildren(sameClosingSituations); using (var view = new GeneralResultFaultTreeIllustrationPointView(() => generalResultFunc) { Data = data @@ -465,22 +499,28 @@ var selectedFaultTreeContext = view.Selection as IllustrationPointNodeContext; Assert.IsNotNull(selectedFaultTreeContext); Assert.AreSame(expectedSelectedNode, selectedFaultTreeContext.IllustrationPointNode); - Assert.AreEqual(topLevel.ClosingSituation, selectedFaultTreeContext.ClosingSituation); + + Assert.AreEqual(sameClosingSituations + ? string.Empty + : topLevel.ClosingSituation, + selectedFaultTreeContext.ClosingSituation); Assert.AreEqual(topLevel.WindDirection.Name, selectedFaultTreeContext.WindDirectionName); } mocks.VerifyAll(); } [Test] - public void GivenFullyConfiguredView_WhenSelectingSubMechanismIllustrationPointInTree_ThenSelectionChangedAndPropagatedAccordingly() + [TestCase(true)] + [TestCase(false)] + public void GivenFullyConfiguredView_WhenSelectingSubMechanismIllustrationPointInTree_ThenSelectionChangedAndPropagatedAccordingly(bool sameClosingSituations) { // Given var mocks = new MockRepository(); var data = mocks.Stub(); mocks.ReplayAll(); - GeneralResult generalResultFunc = GetGeneralResultWithTopLevelIllustrationPointsWithChildren(); + GeneralResult generalResultFunc = GetGeneralResultWithTwoTopLevelIllustrationPointsWithChildren(sameClosingSituations); using (var view = new GeneralResultFaultTreeIllustrationPointView(() => generalResultFunc) { Data = data @@ -507,7 +547,10 @@ var selectedSubMechanismContext = view.Selection as IllustrationPointNodeContext; Assert.IsNotNull(selectedSubMechanismContext); Assert.AreSame(expectedSelectedNode, selectedSubMechanismContext.IllustrationPointNode); - Assert.AreEqual(topLevel.ClosingSituation, selectedSubMechanismContext.ClosingSituation); + Assert.AreEqual(sameClosingSituations + ? string.Empty + : topLevel.ClosingSituation, + selectedSubMechanismContext.ClosingSituation); Assert.AreEqual(topLevel.WindDirection.Name, selectedSubMechanismContext.WindDirectionName); } mocks.VerifyAll();