Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext.cs =================================================================== diff -u --- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext.cs (revision 0) +++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext.cs (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -0,0 +1,71 @@ +// 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; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.DuneErosion.Data; + +namespace Riskeer.DuneErosion.Forms.PresentationObjects +{ + /// + /// Presentation object for all dune location calculations based on user defined target probabilities. + /// + public class DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext : ObservableWrappedObjectContextBase> + { + /// + /// Creates a new instance of . + /// + /// The dune locations wrapped by the context. + /// The failure mechanism the context belongs to. + /// The assessment section the context belongs to. + /// Thrown when any parameter is null. + public DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(IObservableEnumerable wrappedData, + DuneErosionFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(wrappedData) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanism = failureMechanism; + AssessmentSection = assessmentSection; + } + + /// + /// Gets the failure mechanism the context belongs to. + /// + public DuneErosionFailureMechanism FailureMechanism { get; } + + /// + /// Gets the assessment section the context belongs to. + /// + public IAssessmentSection AssessmentSection { get; } + } +} \ No newline at end of file Fisheye: Tag ad7de8440b9293c49d8801d4707d8b5c779634cf refers to a dead (removed) revision in file `Riskeer/DuneErosion/src/Riskeer.DuneErosion.Forms/PresentationObjects/DuneLocationCalculationsGroupContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs =================================================================== diff -u -r3ecc21590188b24f34a0b32170267cd634a1d6d8 -rad7de8440b9293c49d8801d4707d8b5c779634cf --- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision 3ecc21590188b24f34a0b32170267cd634a1d6d8) +++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -108,7 +108,7 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { Text = context => RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName, ForeColor = context => context.WrappedData.Any() @@ -197,7 +197,7 @@ GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), GetFileFilterGenerator()) }; - yield return new ExportInfo + yield return new ExportInfo { Name = RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName, Extension = Resources.DuneErosionPlugin_GetExportInfos_Boundary_conditions_file_filter_Extension, @@ -281,7 +281,7 @@ { new CategoryTreeFolder(RiskeerCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetHydraulicLoadsInputs(wrappedData), TreeFolderCategory.Input), - new DuneLocationCalculationsGroupContext(context.WrappedData.DuneLocations, context.WrappedData, assessmentSection) + new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(context.WrappedData.DuneLocations, context.WrappedData, assessmentSection) }; } @@ -367,7 +367,7 @@ #region DuneLocationCalculationsGroupContext TreeNodeInfo - private ContextMenuStrip DuneLocationCalculationsGroupContextMenuStrip(DuneLocationCalculationsGroupContext nodeData, + private ContextMenuStrip DuneLocationCalculationsGroupContextMenuStrip(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext nodeData, object parentData, TreeViewControl treeViewControl) { @@ -381,7 +381,7 @@ .Build(); } - private static object[] DuneLocationCalculationsGroupContextChildNodeObjects(DuneLocationCalculationsGroupContext context) + private static object[] DuneLocationCalculationsGroupContextChildNodeObjects(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext context) { return !context.WrappedData.Any() ? new object[0] @@ -559,7 +559,7 @@ Resources.DuneErosionPlugin_GetExportInfos_Boundary_conditions_file_filter_Description); } - private static bool IsDuneLocationCalculationsGroupContextExportMenuItemEnabled(DuneLocationCalculationsGroupContext context) + private static bool IsDuneLocationCalculationsGroupContextExportMenuItemEnabled(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext context) { return context.FailureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm.Any(calculation => calculation.Output != null) || context.FailureMechanism.CalculationsForMechanismSpecificSignalingNorm.Any(calculation => calculation.Output != null) @@ -568,7 +568,7 @@ || context.FailureMechanism.CalculationsForFactorizedLowerLimitNorm.Any(calculation => calculation.Output != null); } - private static IFileExporter CreateDuneLocationCalculationsGroupContextFileExporter(DuneLocationCalculationsGroupContext context, string filePath) + private static IFileExporter CreateDuneLocationCalculationsGroupContextFileExporter(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext context, string filePath) { return CreateDuneLocationCalculationsExporter(DuneLocationCalculationsGroupContextChildNodeObjects(context) .Cast() Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContextTest.cs =================================================================== diff -u --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContextTest.cs (revision 0) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContextTest.cs (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -0,0 +1,89 @@ +// 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; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.DuneErosion.Data; +using Riskeer.DuneErosion.Forms.PresentationObjects; + +namespace Riskeer.DuneErosion.Forms.Test.PresentationObjects +{ + [TestFixture] + public class DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var locations = new ObservableList(); + var failureMechanism = new DuneErosionFailureMechanism(); + + // Call + var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext( + locations, failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>>(context); + Assert.AreSame(locations, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSection, context.AssessmentSection); + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + mockRepository.ReplayAll(); + + // Call + void Call() => new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext( + new ObservableList(), null, assessmentSection); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("failureMechanism", exception.ParamName); + mockRepository.VerifyAll(); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext( + new ObservableList(), new DuneErosionFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + } +} \ No newline at end of file Fisheye: Tag ad7de8440b9293c49d8801d4707d8b5c779634cf refers to a dead (removed) revision in file `Riskeer/DuneErosion/test/Riskeer.DuneErosion.Forms.Test/PresentationObjects/DuneLocationCalculationsGroupContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs =================================================================== diff -u -r15feb31eff60ab29cc9780b16be96d9baab54cd6 -rad7de8440b9293c49d8801d4707d8b5c779634cf --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs (.../DuneErosionPluginTest.cs) (revision 15feb31eff60ab29cc9780b16be96d9baab54cd6) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/DuneErosionPluginTest.cs (.../DuneErosionPluginTest.cs) (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -108,7 +108,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneErosionHydraulicLoadsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneErosionFailurePathContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneLocationCalculationsGroupContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilityContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DuneLocationCalculationsContext))); } @@ -162,7 +162,7 @@ // Assert Assert.AreEqual(2, exportInfos.Length); Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(DuneLocationCalculationsContext))); - Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(DuneLocationCalculationsGroupContext))); + Assert.IsTrue(exportInfos.Any(ei => ei.DataType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext))); } } Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ExportInfos/DuneLocationCalculationsGroupContextExportInfoTest.cs =================================================================== diff -u -r3af63470ea5601aef5eb9f1f796bf2342b406fca -rad7de8440b9293c49d8801d4707d8b5c779634cf --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ExportInfos/DuneLocationCalculationsGroupContextExportInfoTest.cs (.../DuneLocationCalculationsGroupContextExportInfoTest.cs) (revision 3af63470ea5601aef5eb9f1f796bf2342b406fca) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/ExportInfos/DuneLocationCalculationsGroupContextExportInfoTest.cs (.../DuneLocationCalculationsGroupContextExportInfoTest.cs) (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -68,9 +68,9 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var context = new DuneLocationCalculationsGroupContext(new ObservableList(), - new DuneErosionFailureMechanism(), - assessmentSection); + var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -99,9 +99,9 @@ { new TestDuneLocation() }); - var context = new DuneLocationCalculationsGroupContext(new ObservableList(), - failureMechanism, - assessmentSection); + var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -131,9 +131,9 @@ { new TestDuneLocation() }); - var context = new DuneLocationCalculationsGroupContext(new ObservableList(), - failureMechanism, - assessmentSection); + var context = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); getCalculationsFunc(context.FailureMechanism).Single().Output = new TestDuneLocationCalculationOutput(); using (var plugin = new DuneErosionPlugin()) @@ -152,7 +152,7 @@ private static ExportInfo GetExportInfo(DuneErosionPlugin plugin) { - return plugin.GetExportInfos().First(ei => ei.DataType == typeof(DuneLocationCalculationsGroupContext)); + return plugin.GetExportInfos().First(ei => ei.DataType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext)); } private static IEnumerable GetCalculationListFuncs() Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs =================================================================== diff -u -r1dd2c22368f99235c15314f434505d4b5fc27a90 -rad7de8440b9293c49d8801d4707d8b5c779634cf --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs (.../DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs) (revision 1dd2c22368f99235c15314f434505d4b5fc27a90) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs (.../DuneErosionHydraulicLoadsContextTreeNodeInfoTest.cs) (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -127,7 +127,7 @@ var inputComment = (Comment) inputsFolder.Contents.ElementAt(0); Assert.AreSame(failureMechanism.InputComments, inputComment); - var duneLocationCalculationsGroupContext = (DuneLocationCalculationsGroupContext) children[1]; + var duneLocationCalculationsGroupContext = (DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext) children[1]; Assert.AreSame(failureMechanism.DuneLocations, duneLocationCalculationsGroupContext.WrappedData); Assert.AreSame(failureMechanism, duneLocationCalculationsGroupContext.FailureMechanism); Assert.AreSame(assessmentSection, duneLocationCalculationsGroupContext.AssessmentSection); Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneLocationCalculationsGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb0899d90d287d9e53b52b7573a0c0fd66120fa16 -rad7de8440b9293c49d8801d4707d8b5c779634cf --- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneLocationCalculationsGroupContextTreeNodeInfoTest.cs (.../DuneLocationCalculationsGroupContextTreeNodeInfoTest.cs) (revision b0899d90d287d9e53b52b7573a0c0fd66120fa16) +++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Plugin.Test/TreeNodeInfos/DuneLocationCalculationsGroupContextTreeNodeInfoTest.cs (.../DuneLocationCalculationsGroupContextTreeNodeInfoTest.cs) (revision ad7de8440b9293c49d8801d4707d8b5c779634cf) @@ -114,7 +114,7 @@ var failureMechanism = new DuneErosionFailureMechanism(); var locations = new ObservableList(); - var calculationsGroupContext = new DuneLocationCalculationsGroupContext(locations, failureMechanism, assessmentSection); + var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(locations, failureMechanism, assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -139,7 +139,7 @@ new TestDuneLocation() }; - var calculationsGroupContext = new DuneLocationCalculationsGroupContext(locations, failureMechanism, assessmentSection); + var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(locations, failureMechanism, assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -191,9 +191,9 @@ orderedMockRepository.ReplayAll(); - var nodeData = new DuneLocationCalculationsGroupContext(new ObservableList(), - new DuneErosionFailureMechanism(), - assessmentSection); + var nodeData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + new DuneErosionFailureMechanism(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -237,7 +237,7 @@ { new TestDuneLocation() }; - var calculationsGroupContext = new DuneLocationCalculationsGroupContext(locations, failureMechanism, assessmentSection); + var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(locations, failureMechanism, assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -289,7 +289,7 @@ assessmentSection.FailureMechanismContribution.SignalingNorm = signalingNorm; var locations = new ObservableList(); - var calculationsGroupContext = new DuneLocationCalculationsGroupContext(locations, new DuneErosionFailureMechanism(), assessmentSection); + var calculationsGroupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(locations, new DuneErosionFailureMechanism(), assessmentSection); using (var plugin = new DuneErosionPlugin()) { @@ -316,9 +316,9 @@ duneLocation }); - var groupContext = new DuneLocationCalculationsGroupContext(new ObservableList(), - failureMechanism, - assessmentSection); + var groupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); var mocks = new MockRepository(); @@ -366,9 +366,9 @@ }; HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase); - var groupContext = new DuneLocationCalculationsGroupContext(new ObservableList(), - failureMechanism, - assessmentSection); + var groupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); var mocks = new MockRepository(); @@ -426,16 +426,16 @@ duneLocation }); - var groupContext = new DuneLocationCalculationsGroupContext(new ObservableList(), - failureMechanism, - assessmentSection); + var groupContext = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList(), + failureMechanism, + assessmentSection); var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks); - + var gui = mocks.Stub(); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); @@ -506,7 +506,7 @@ private static TreeNodeInfo GetInfo(DuneErosionPlugin plugin) { - return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DuneLocationCalculationsGroupContext)); + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext)); } } } \ No newline at end of file