Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj =================================================================== diff -u -rb1ac808731908913604250220e5c215c2cfe37a8 -rddaf60d416770fed7e16937e4081388da4d2a770 --- Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj (.../Riskeer.Piping.Forms.csproj) (revision b1ac808731908913604250220e5c215c2cfe37a8) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/Riskeer.Piping.Forms.csproj (.../Riskeer.Piping.Forms.csproj) (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -59,7 +59,7 @@ True Resources.resx - + UserControl Fisheye: Tag ddaf60d416770fed7e16937e4081388da4d2a770 refers to a dead (removed) revision in file `Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointView.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingProfileSpecificOutputView.cs =================================================================== diff -u --- Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingProfileSpecificOutputView.cs (revision 0) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/Views/ProbabilisticPipingProfileSpecificOutputView.cs (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -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 ProbabilisticPipingProfileSpecificOutputView : GeneralResultFaultTreeIllustrationPointView + { + /// + /// Creates a new instance of . + /// + /// A for obtaining the illustration point + /// data ( with objects) + /// that must be presented. + /// Thrown when is null. + public ProbabilisticPipingProfileSpecificOutputView(Func> getGeneralResultFunc) + : base(getGeneralResultFunc) {} + } +} \ No newline at end of file Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -rb1ac808731908913604250220e5c215c2cfe37a8 -rddaf60d416770fed7e16937e4081388da4d2a770 --- Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision b1ac808731908913604250220e5c215c2cfe37a8) +++ Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -283,25 +283,23 @@ yield return new ViewInfo, FailureMechanismSectionsProbabilityAssessmentView> { + GetViewData = context => context.WrappedData.Sections, GetViewName = (view, context) => RiskeerCommonFormsResources.FailureMechanismSections_DisplayName, Image = RiskeerCommonFormsResources.SectionsIcon, CloseForData = RiskeerPluginHelper.ShouldCloseForFailureMechanismView, CreateInstance = context => new FailureMechanismSectionsProbabilityAssessmentView(context.WrappedData.Sections, context.WrappedData, - ((PipingFailureMechanism) context.WrappedData).PipingProbabilityAssessmentInput), - GetViewData = context => context.WrappedData.Sections + ((PipingFailureMechanism) context.WrappedData).PipingProbabilityAssessmentInput) }; - yield return new ViewInfo + yield return new ViewInfo { - Image = RiskeerCommonFormsResources.GeneralOutputIcon, - // Check view name - GetViewName = (view, context) => RiskeerCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetViewData = context => context.WrappedData, + GetViewName = (view, context) => PipingFormsResources.ProbabilisticProfileSpecificOutput_DisplayName, + Image = RiskeerCommonFormsResources.GeneralOutputIcon, CloseForData = RiskeerPluginHelper.ShouldCloseViewWithCalculationData, - // Check specific output! - CreateInstance = context => new ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointView( - () => context.WrappedData.Output?.SectionSpecificOutput?.GeneralResult) + CreateInstance = context => new ProbabilisticPipingProfileSpecificOutputView( + () => context.WrappedData.Output?.ProfileSpecificOutput?.GeneralResult) }; } Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewTest.cs =================================================================== diff -u -rb1ac808731908913604250220e5c215c2cfe37a8 -rddaf60d416770fed7e16937e4081388da4d2a770 --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewTest.cs (.../ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewTest.cs) (revision b1ac808731908913604250220e5c215c2cfe37a8) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/Views/ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewTest.cs (.../ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewTest.cs) (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -35,7 +35,7 @@ public void Constructor_ExpectedValues() { // Call - var view = new ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()); + var view = new ProbabilisticPipingProfileSpecificOutputView(() => new TestGeneralResultFaultTreeIllustrationPoint()); // Assert Assert.IsInstanceOf(view); Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -r8c4d35d0b96951a340d4ba22d2671284918188b9 -rddaf60d416770fed7e16937e4081388da4d2a770 --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 8c4d35d0b96951a340d4ba22d2671284918188b9) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -171,7 +171,7 @@ ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(7, viewInfos.Length); + Assert.AreEqual(8, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, @@ -213,6 +213,12 @@ typeof(PipingFailureMechanismSectionsContext), typeof(IEnumerable), typeof(FailureMechanismSectionsProbabilityAssessmentView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, + typeof(ProbabilisticPipingProfileSpecificOutputContext), + typeof(ProbabilisticPipingCalculation), + typeof(ProbabilisticPipingProfileSpecificOutputView)); } } Fisheye: Tag ddaf60d416770fed7e16937e4081388da4d2a770 refers to a dead (removed) revision in file `Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingOutputGeneralResultFaultTreeIllustrationPointViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingProfileSpecificOutputViewInfoTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingProfileSpecificOutputViewInfoTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ViewInfos/ProbabilisticPipingProfileSpecificOutputViewInfoTest.cs (revision ddaf60d416770fed7e16937e4081388da4d2a770) @@ -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 ProbabilisticPipingProfileSpecificOutputViewInfoTest + { + 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(ProbabilisticPipingProfileSpecificOutputView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(ProbabilisticPipingProfileSpecificOutputContext), info.DataType); + Assert.AreEqual(typeof(ProbabilisticPipingCalculation), info.ViewDataType); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GeneralOutputIcon, info.Image); + } + + [Test] + public void GetViewData_Always_ReturnsWrappedCalculationScenario() + { + // Setup + var calculationScenario = new ProbabilisticPipingCalculationScenario(); + var pipingScenariosContext = new ProbabilisticPipingProfileSpecificOutputContext(calculationScenario); + + // Call + object viewData = info.GetViewData(pipingScenariosContext); + + // Assert + Assert.AreSame(calculationScenario, viewData); + } + + [Test] + public void GetViewName_Always_ReturnsCorrectViewName() + { + // Call + string viewName = info.GetViewName(null, null); + + // Assert + Assert.AreEqual("Resultaat doorsnede", 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 ProbabilisticPipingProfileSpecificOutputView(() => 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 ProbabilisticPipingProfileSpecificOutputContext(new ProbabilisticPipingCalculationScenario()); + + // Call + IView view = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(view); + } + + [TestFixture] + public class ProbabilisticPipingProfileSpecificOutputViewTester : ShouldCloseViewWithCalculationDataTester + { + protected override bool ShouldCloseMethod(IView view, object o) + { + using (var plugin = new PipingPlugin()) + { + return plugin.GetViewInfos() + .First(tni => tni.ViewType == typeof(ProbabilisticPipingProfileSpecificOutputView)) + .CloseForData(view, o); + } + } + + protected override IView GetView(ICalculation data) + { + return new ProbabilisticPipingProfileSpecificOutputView(() => 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