Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismResultViewInfoTest.cs
===================================================================
diff -u
--- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismResultViewInfoTest.cs (revision 0)
+++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverFailureMechanismResultViewInfoTest.cs (revision 6e5a2fa750de80c293d0c816580ece7c77cb9724)
@@ -0,0 +1,282 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Linq;
+using Core.Common.Base;
+using Core.Common.Controls.Views;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Forms.Views;
+using Riskeer.StabilityStoneCover.Data;
+using Riskeer.StabilityStoneCover.Forms.PresentationObjects;
+
+namespace Riskeer.StabilityStoneCover.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverFailureMechanismResultViewInfoTest
+ {
+ private MockRepository mocks;
+ private StabilityStoneCoverPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new StabilityStoneCoverPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(NonAdoptableWithProfileProbabilityFailureMechanismResultView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(StabilityStoneCoverFailureMechanismSectionResultContext), info.DataType);
+ Assert.AreEqual(typeof(IObservableEnumerable), info.ViewDataType);
+ }
+
+ [Test]
+ public void GetViewData_WithContext_ReturnsWrappedFailureMechanismResult()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverFailureMechanismSectionResultContext(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection);
+
+ // Call
+ object viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreSame(failureMechanism.SectionResults, viewData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsViewName()
+ {
+ // Call
+ string viewName = info.GetViewName(null, null);
+
+ // Assert
+ Assert.AreEqual("Resultaat", viewName);
+ }
+
+ [Test]
+ public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[0]);
+
+ mocks.ReplayAll();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var otherFailureMechanism = mocks.Stub();
+
+ assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new[]
+ {
+ otherFailureMechanism
+ });
+
+ mocks.ReplayAll();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new IFailureMechanism[]
+ {
+ failureMechanism
+ });
+
+ mocks.ReplayAll();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, failureMechanism);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, new StabilityStoneCoverFailureMechanism());
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailurePathContext_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverFailurePathContext(failureMechanism, assessmentSection);
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailurePathContext_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var context = new StabilityStoneCoverFailurePathContext(new StabilityStoneCoverFailureMechanism(), assessmentSection);
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+
+ using (var view = new NonAdoptableWithProfileProbabilityFailureMechanismResultView(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection, fm => double.NaN, fm => false))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_ReturnsView()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverFailureMechanismSectionResultContext(
+ failureMechanism.SectionResults, failureMechanism, assessmentSection);
+
+ // Call
+ IView view = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf>(view);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 6e5a2fa750de80c293d0c816580ece7c77cb9724 refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverResultViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?