Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj
===================================================================
diff -u -rddaf60d416770fed7e16937e4081388da4d2a770 -rab4cdd9bbd7fcf904c28b8f564e7503f726db686
--- Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj (.../Riskeer.Piping.Forms.csproj) (revision ddaf60d416770fed7e16937e4081388da4d2a770)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj (.../Riskeer.Piping.Forms.csproj) (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -59,6 +59,9 @@
True
Resources.resx
+
+ UserControl
+
UserControl
Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingSectionSpecificOutputView.cs
===================================================================
diff -u
--- Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingSectionSpecificOutputView.cs (revision 0)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingSectionSpecificOutputView.cs (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -0,0 +1,45 @@
+// Copyright (C) Stichting Deltares 2019. 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;
+using Riskeer.Common.Data.IllustrationPoints;
+using Riskeer.Common.Forms.Views;
+using Riskeer.Piping.Data.Probabilistic;
+
+namespace Riskeer.Piping.Forms.Views
+{
+ ///
+ /// Override of for making output views for
+ /// uniquely identifiable (when it comes to opening/closing views).
+ ///
+ public class ProbabilisticPipingSectionSpecificOutputView : GeneralResultFaultTreeIllustrationPointView
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// A for obtaining the illustration point
+ /// data ( with objects)
+ /// that must be presented.
+ /// Thrown when is null.
+ public ProbabilisticPipingSectionSpecificOutputView(Func> getGeneralResultFunc)
+ : base(getGeneralResultFunc) {}
+ }
+}
\ No newline at end of file
Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -rddaf60d416770fed7e16937e4081388da4d2a770 -rab4cdd9bbd7fcf904c28b8f564e7503f726db686
--- Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision ddaf60d416770fed7e16937e4081388da4d2a770)
+++ Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -301,6 +301,16 @@
CreateInstance = context => new ProbabilisticPipingProfileSpecificOutputView(
() => context.WrappedData.Output?.ProfileSpecificOutput?.GeneralResult)
};
+
+ yield return new ViewInfo
+ {
+ GetViewData = context => context.WrappedData,
+ GetViewName = (view, context) => PipingFormsResources.ProbabilisticSectionSpecificOutput_DisplayName,
+ Image = RiskeerCommonFormsResources.GeneralOutputIcon,
+ CloseForData = RiskeerPluginHelper.ShouldCloseViewWithCalculationData,
+ CreateInstance = context => new ProbabilisticPipingSectionSpecificOutputView(
+ () => context.WrappedData.Output?.SectionSpecificOutput?.GeneralResult)
+ };
}
public override IEnumerable GetTreeNodeInfos()
Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingSectionSpecificOutputViewTest.cs
===================================================================
diff -u
--- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingSectionSpecificOutputViewTest.cs (revision 0)
+++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingSectionSpecificOutputViewTest.cs (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -0,0 +1,45 @@
+// Copyright (C) Stichting Deltares 2019. 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.Threading;
+using NUnit.Framework;
+using Riskeer.Common.Data.TestUtil.IllustrationPoints;
+using Riskeer.Common.Forms.Views;
+using Riskeer.Piping.Forms.Views;
+
+namespace Riskeer.Piping.Forms.Test.Views
+{
+ [TestFixture]
+ [Apartment(ApartmentState.STA)]
+ public class ProbabilisticPipingSectionSpecificOutputViewTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var view = new ProbabilisticPipingSectionSpecificOutputView(() => new TestGeneralResultFaultTreeIllustrationPoint());
+
+ // Assert
+ Assert.IsInstanceOf(view);
+ }
+
+ }
+}
Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs
===================================================================
diff -u -re5149a7ed53dfe98cae93c8f7376ae92b5d8f5f4 -rab4cdd9bbd7fcf904c28b8f564e7503f726db686
--- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision e5149a7ed53dfe98cae93c8f7376ae92b5d8f5f4)
+++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -171,7 +171,7 @@
ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray();
// Assert
- Assert.AreEqual(8, viewInfos.Length);
+ Assert.AreEqual(9, viewInfos.Length);
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
@@ -219,6 +219,12 @@
typeof(ProbabilisticPipingProfileSpecificOutputContext),
typeof(ProbabilisticPipingCalculationScenario),
typeof(ProbabilisticPipingProfileSpecificOutputView));
+
+ PluginTestHelper.AssertViewInfoDefined(
+ viewInfos,
+ typeof(ProbabilisticPipingSectionSpecificOutputContext),
+ typeof(ProbabilisticPipingCalculationScenario),
+ typeof(ProbabilisticPipingSectionSpecificOutputView));
}
}
Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingSectionSpecificOutputViewInfoTest.cs
===================================================================
diff -u
--- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingSectionSpecificOutputViewInfoTest.cs (revision 0)
+++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingSectionSpecificOutputViewInfoTest.cs (revision ab4cdd9bbd7fcf904c28b8f564e7503f726db686)
@@ -0,0 +1,211 @@
+// Copyright (C) Stichting Deltares 2019. 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 System.Threading;
+using Core.Common.Controls.Views;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Data.TestUtil.IllustrationPoints;
+using Riskeer.Common.Forms.PresentationObjects;
+using Riskeer.Common.Plugin.TestUtil;
+using Riskeer.Piping.Data;
+using Riskeer.Piping.Data.Probabilistic;
+using Riskeer.Piping.Data.SoilProfile;
+using Riskeer.Piping.Forms.PresentationObjects;
+using Riskeer.Piping.Forms.PresentationObjects.Probabilistic;
+using Riskeer.Piping.Forms.Views;
+using Riskeer.Piping.Primitives;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Piping.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ [Apartment(ApartmentState.STA)]
+ public class ProbabilisticPipingSectionSpecificOutputViewInfoTest
+ {
+ private MockRepository mocks;
+ private PipingPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new PipingPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(ProbabilisticPipingSectionSpecificOutputView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(ProbabilisticPipingSectionSpecificOutputContext), info.DataType);
+ Assert.AreEqual(typeof(ProbabilisticPipingCalculationScenario), info.ViewDataType);
+ TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralOutputIcon, info.Image);
+ }
+
+ [Test]
+ public void GetViewData_WithContext_ReturnsWrappedCalculationScenario()
+ {
+ // Setup
+ var calculationScenario = new ProbabilisticPipingCalculationScenario();
+ var context = new ProbabilisticPipingSectionSpecificOutputContext(calculationScenario);
+
+ // Call
+ object viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreSame(calculationScenario, viewData);
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsCorrectViewName()
+ {
+ // Call
+ string viewName = info.GetViewName(null, null);
+
+ // Assert
+ Assert.AreEqual("Resultaat vak", viewName);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ var assessmentSection = mocks.Stub();
+ assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new[]
+ {
+ failureMechanism
+ });
+
+ mocks.ReplayAll();
+
+ using (var view = new ProbabilisticPipingSectionSpecificOutputView(() => new TestGeneralResultFaultTreeIllustrationPoint()))
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_ReturnsView()
+ {
+ // Setup
+ var context = new ProbabilisticPipingSectionSpecificOutputContext(new ProbabilisticPipingCalculationScenario());
+
+ // Call
+ IView view = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(view);
+ }
+
+ [TestFixture]
+ public class ProbabilisticPipingSectionSpecificOutputViewTester : ShouldCloseViewWithCalculationDataTester
+ {
+ protected override bool ShouldCloseMethod(IView view, object o)
+ {
+ using (var plugin = new PipingPlugin())
+ {
+ return plugin.GetViewInfos()
+ .First(tni => tni.ViewType == typeof(ProbabilisticPipingSectionSpecificOutputView))
+ .CloseForData(view, o);
+ }
+ }
+
+ protected override IView GetView(ICalculation data)
+ {
+ return new ProbabilisticPipingSectionSpecificOutputView(() => new TestGeneralResultFaultTreeIllustrationPoint())
+ {
+ Data = data
+ };
+ }
+
+ protected override ICalculation GetCalculation()
+ {
+ return new ProbabilisticPipingCalculationScenario();
+ }
+
+ protected override ICalculationContext GetCalculationContextWithCalculation()
+ {
+ return new ProbabilisticPipingCalculationScenarioContext(
+ new ProbabilisticPipingCalculationScenario(),
+ new CalculationGroup(),
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ new PipingFailureMechanism(),
+ new AssessmentSectionStub());
+ }
+
+ protected override ICalculationContext GetCalculationGroupContextWithCalculation()
+ {
+ return new PipingCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ new ProbabilisticPipingCalculationScenario()
+ }
+ },
+ null,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ new PipingFailureMechanism(),
+ new AssessmentSectionStub());
+ }
+
+ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation()
+ {
+ return new PipingFailureMechanismContext(
+ new PipingFailureMechanism
+ {
+ CalculationsGroup =
+ {
+ Children =
+ {
+ new ProbabilisticPipingCalculationScenario()
+ }
+ }
+ }, new AssessmentSectionStub());
+ }
+ }
+ }
+}
\ No newline at end of file