Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rf3b9d5377e02249b6cd172539692b4b61c41058b -rece73dfb8d18b9338adfb6fff3d38925f0867cff --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision f3b9d5377e02249b6cd172539692b4b61c41058b) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision ece73dfb8d18b9338adfb6fff3d38925f0867cff) @@ -104,7 +104,8 @@ { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, - CreateInstance = context => new ClosingStructuresFailurePathView(context.WrappedData, context.Parent) + CreateInstance = context => new ClosingStructuresFailurePathView(context.WrappedData, context.Parent), + CloseForData = CloseFailurePathViewForData }; yield return new ViewInfo< @@ -288,6 +289,16 @@ #region ViewInfos + private static bool CloseFailurePathViewForData(ClosingStructuresFailurePathView view, object dataToCloseFor) + { + var assessmentSection = dataToCloseFor as IAssessmentSection; + var failureMechanism = dataToCloseFor as ClosingStructuresFailureMechanism; + + return assessmentSection != null + ? ReferenceEquals(view.AssessmentSection, assessmentSection) + : ReferenceEquals(view.FailureMechanism, failureMechanism); + } + private static bool CloseFailureMechanismResultViewForData(ClosingStructuresFailureMechanismResultView view, object dataToCloseFor) { ClosingStructuresFailureMechanism failureMechanism = null; Index: Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailurePathViewInfoTest.cs =================================================================== diff -u -rfc05d28b1d3b14433c890521c0f276ab14b73506 -rece73dfb8d18b9338adfb6fff3d38925f0867cff --- Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailurePathViewInfoTest.cs (.../ClosingStructuresFailurePathViewInfoTest.cs) (revision fc05d28b1d3b14433c890521c0f276ab14b73506) +++ Riskeer/ClosingStructures/test/Riskeer.ClosingStructures.Plugin.Test/ViewInfos/ClosingStructuresFailurePathViewInfoTest.cs (.../ClosingStructuresFailurePathViewInfoTest.cs) (revision ece73dfb8d18b9338adfb6fff3d38925f0867cff) @@ -115,5 +115,75 @@ Assert.AreSame(assessmentSection, view.AssessmentSection); } } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var otherAssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var view = new ClosingStructuresFailurePathView(failureMechanism, assessmentSection); + + // Call + bool closeForData = info.CloseForData(view, otherAssessmentSection); + + // Assert + Assert.IsFalse(closeForData); + + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var view = new ClosingStructuresFailurePathView(failureMechanism, assessmentSection); + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var otherClosingStructuresFailureMechanism = new ClosingStructuresFailureMechanism(); + + var view = new ClosingStructuresFailurePathView(failureMechanism, assessmentSection); + + // Call + bool closeForData = info.CloseForData(view, otherClosingStructuresFailureMechanism); + + // Assert + Assert.IsFalse(closeForData); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var view = new ClosingStructuresFailurePathView(failureMechanism, assessmentSection); + + // Call + bool closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } } } \ No newline at end of file