Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsTreeNodeInfoFactory.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsTreeNodeInfoFactory.cs (.../RingtoetsTreeNodeInfoFactory.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsTreeNodeInfoFactory.cs (.../RingtoetsTreeNodeInfoFactory.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -57,7 +57,7 @@ { Text = context => context.WrappedData.Name, Image = context => Resources.GeneralFolderIcon, - EnsureVisibleOnCreate = (context, parent) => !(parent is IFailureMechanismContext), + EnsureVisibleOnCreate = (context, parent) => (parent is ICalculationContext), ChildNodeObjects = childNodeObjects, ContextMenuStrip = contextMenuStrip, CanRename = (context, parentData) => IsNestedGroup(parentData), Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs (.../RingtoetsTreeNodeInfoFactoryTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs (.../RingtoetsTreeNodeInfoFactoryTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -105,26 +105,26 @@ } [Test] - public void EnsureVisibleOnCreate_CalculationGroup_ForFailureMechanismCalculationGroup_ReturnsFalse() + public void EnsureVisibleOnCreate_CalculationGroup_ForCalculationGroup_ReturnsTrue() { // Setup var mocks = new MockRepository(); - var failureMechanismMock = mocks.StrictMock>(); + var calculationGroup = new TestCalculationGroupContext(new CalculationGroup(), mocks.Stub()); mocks.ReplayAll(); var treeNodeInfo = RingtoetsTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(null, null, null); // Call - var result = treeNodeInfo.EnsureVisibleOnCreate(null, failureMechanismMock); + var result = treeNodeInfo.EnsureVisibleOnCreate(null, calculationGroup); // Assert - Assert.IsFalse(result); + Assert.IsTrue(result); mocks.VerifyAll(); } [Test] - public void EnsureVisibleOnCreate_CalculationGroup_AnyOtherObject_ReturnsTrue() + public void EnsureVisibleOnCreate_CalculationGroup_AnyOtherObject_ReturnsFalse() { // Setup var treeNodeInfo = RingtoetsTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(null, null, null); @@ -133,7 +133,7 @@ var result = treeNodeInfo.EnsureVisibleOnCreate(null, null); // Assert - Assert.IsTrue(result); + Assert.IsFalse(result); } [Test] Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs =================================================================== diff -u -rf2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs (.../HydraulicBoundariesGroupContext.cs) (revision f2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/HydraulicBoundariesGroupContext.cs (.../HydraulicBoundariesGroupContext.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -20,36 +20,51 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.HydraRing.Data; namespace Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects { /// /// Presentation object for Hydraulic boundary locations and calculations. /// - public class HydraulicBoundariesGroupContext : ObservableWrappedObjectContextBase + public class HydraulicBoundariesGroupContext : ObservableWrappedObjectContextBase> { /// /// Initializes a new instance of the class. /// - /// The failure mechanism which the context belongs to. - /// The assessment section this context belongs to. + /// The locations from the hydraulic boundaries database made for grass cover erosion outwards. + /// The grass cover erosion outwards failure mechanism which the locations belong to. + /// The assessment section the locations belong to. /// Thrown when any input argument is null. - public HydraulicBoundariesGroupContext(GrassCoverErosionOutwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) - : base(failureMechanism) + public HydraulicBoundariesGroupContext(ObservableList hydraulicBoundaryLocations, + GrassCoverErosionOutwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(hydraulicBoundaryLocations) { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } if (assessmentSection == null) { throw new ArgumentNullException("assessmentSection"); } AssessmentSection = assessmentSection; + FailureMechanism = failureMechanism; } /// /// Gets the assessment section. /// public IAssessmentSection AssessmentSection { get; private set; } + + /// + /// Gets the failure mechanism. + /// + public GrassCoverErosionOutwardsFailureMechanism FailureMechanism { get; private set; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r538841777d95e5ccf83651d5d67002453ec750bc -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 538841777d95e5ccf83651d5d67002453ec750bc) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -139,18 +139,6 @@ }; } - private bool CloseDesignWaterLevelLocationsViewForData(GrassCoverErosionOutwardsDesignWaterLevelLocationsView view, object dataToCloseFor) - { - var section = dataToCloseFor as IAssessmentSection; - var failureMechanismContext = dataToCloseFor as GrassCoverErosionOutwardsFailureMechanismContext; - - var viewAssessmentSection = view.AssessmentSection; - var closeForFailureMechanism = failureMechanismContext != null && ReferenceEquals(failureMechanismContext.Parent, viewAssessmentSection); - var closeForSection = section != null && ReferenceEquals(section, viewAssessmentSection); - - return closeForSection || closeForFailureMechanism; - } - public override IEnumerable GetTreeNodeInfos() { yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo( @@ -188,26 +176,23 @@ .AddSeparator() .AddExpandAllItem() .AddCollapseAllItem() - .Build() + .Build(), + ForeColor = context => context.AssessmentSection.HydraulicBoundaryDatabase == null ? + Color.FromKnownColor(KnownColor.GrayText) : + Color.FromKnownColor(KnownColor.ControlText) }; yield return new TreeNodeInfo { Text = context => RingtoetsGrassCoverErosionOutwardsFormsResources.GrassCoverErosionOutwardsWaterLevelLocations_DisplayName, Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon, - ForeColor = context => context.AssessmentSection.HydraulicBoundaryDatabase == null ? - Color.FromKnownColor(KnownColor.GrayText) : - Color.FromKnownColor(KnownColor.ControlText), ContextMenuStrip = GrassCoverErosionOutwardsDesignWaterLevelLocationsContextMenuStrip }; yield return new TreeNodeInfo { Text = context => RingtoetsGrassCoverErosionOutwardsFormsResources.GrassCoverErosionOutwardsWaveHeightLocationsContext_DisplayName, Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon, - ForeColor = context => context.AssessmentSection.HydraulicBoundaryDatabase == null ? - Color.FromKnownColor(KnownColor.GrayText) : - Color.FromKnownColor(KnownColor.ControlText), ContextMenuStrip = GrassCoverErosionOutwardsWaveHeightLocationsContextMenuStrip }; @@ -248,9 +233,9 @@ Category = RingtoetsCommonFormsResources.Ringtoets_Category, Image = RingtoetsCommonFormsResources.PointShapefileIcon, CreateFileExporter = (context, filePath) => - new HydraulicBoundaryLocationsExporter(context.WrappedData.HydraulicBoundaryLocations, + new HydraulicBoundaryLocationsExporter(context.WrappedData, filePath, Resources.DesignWaterLevel_Description, Resources.WaveHeight_Description), - IsEnabled = context => context.WrappedData.HydraulicBoundaryLocations.Count > 0, + IsEnabled = context => context.WrappedData.Count > 0, FileFilter = RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter }; @@ -261,10 +246,10 @@ Image = RingtoetsCommonFormsResources.GeneralOutputIcon, CreateFileExporter = (context, filePath) => { - var calculations = context.WrappedData.WaveConditionsCalculationGroup.GetCalculations().Cast(); + var calculations = context.FailureMechanism.WaveConditionsCalculationGroup.GetCalculations().Cast(); return new GrassCoverErosionOutwardsWaveConditionsExporter(calculations, filePath); }, - IsEnabled = context => context.WrappedData.WaveConditionsCalculationGroup.GetCalculations().Cast().Any(c => c.HasOutput), + IsEnabled = context => context.FailureMechanism.WaveConditionsCalculationGroup.GetCalculations().Cast().Any(c => c.HasOutput), FileFilter = RingtoetsCommonFormsResources.DataTypeDisplayName_csv_file_filter }; @@ -354,7 +339,7 @@ return new object[] { new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(failureMechanism, failureMechanismContext.Parent), TreeFolderCategory.Input), - new HydraulicBoundariesGroupContext(failureMechanism, failureMechanismContext.Parent), + new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, failureMechanismContext.Parent), new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(failureMechanism), TreeFolderCategory.Output) }; } @@ -417,13 +402,18 @@ private object[] GetHydraulicBoundariesGroupContextChildNodeObjects(HydraulicBoundariesGroupContext hydraulicBoundariesGroupContext) { IAssessmentSection assessmentSection = hydraulicBoundariesGroupContext.AssessmentSection; - ObservableList locations = hydraulicBoundariesGroupContext.WrappedData.HydraulicBoundaryLocations; + if (assessmentSection.HydraulicBoundaryDatabase == null) + { + return new object[0]; + } + + ObservableList locations = hydraulicBoundariesGroupContext.WrappedData; return new object[] { new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(locations, assessmentSection), new GrassCoverErosionOutwardsWaveHeightLocationsContext(locations, assessmentSection), - new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(hydraulicBoundariesGroupContext.WrappedData.WaveConditionsCalculationGroup, - hydraulicBoundariesGroupContext.WrappedData, + new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(hydraulicBoundariesGroupContext.FailureMechanism.WaveConditionsCalculationGroup, + hydraulicBoundariesGroupContext.FailureMechanism, assessmentSection) }; } @@ -478,12 +468,26 @@ } return Gui.Get(nodeData, treeViewControl) + .AddOpenItem() + .AddSeparator() .AddCustomItem(designWaterLevelItem) .AddSeparator() .AddPropertiesItem() .Build(); } + private bool CloseDesignWaterLevelLocationsViewForData(GrassCoverErosionOutwardsDesignWaterLevelLocationsView view, object dataToCloseFor) + { + var section = dataToCloseFor as IAssessmentSection; + var failureMechanismContext = dataToCloseFor as GrassCoverErosionOutwardsFailureMechanismContext; + + var viewAssessmentSection = view.AssessmentSection; + var closeForFailureMechanism = failureMechanismContext != null && ReferenceEquals(failureMechanismContext.Parent, viewAssessmentSection); + var closeForSection = section != null && ReferenceEquals(section, viewAssessmentSection); + + return closeForSection || closeForFailureMechanism; + } + #endregion #region GrassCoverErosionOutwardsWaveHeightLocationsContext TreeNodeInfo Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs =================================================================== diff -u -rcf5500705e6163f283ab151a0a489bbfe60d2f7e -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision cf5500705e6163f283ab151a0a489bbfe60d2f7e) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -88,7 +88,7 @@ mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call IFileExporter fileExporter = hydraulicBoundaryLocationsExporterExportInfo.CreateFileExporter(context, "test"); @@ -107,7 +107,7 @@ mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call bool isEnabled = hydraulicBoundaryLocationsExporterExportInfo.IsEnabled(context); @@ -132,7 +132,7 @@ } }); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call bool isEnabled = hydraulicBoundaryLocationsExporterExportInfo.IsEnabled(context); @@ -184,7 +184,7 @@ mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call IFileExporter fileExporter = waveConditionsExporterExportInfo.CreateFileExporter(context, "test"); @@ -203,7 +203,7 @@ mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); @@ -222,7 +222,7 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); failureMechanism.WaveConditionsCalculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); @@ -244,7 +244,7 @@ Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()) }); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs =================================================================== diff -u -rf2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs (.../HydraulicBoundariesGroupContextTest.cs) (revision f2be29fe8c407a4f32cb1bfcbaf4816c1f99c83f) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/HydraulicBoundariesGroupContextTest.cs (.../HydraulicBoundariesGroupContextTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -20,12 +20,14 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.HydraRing.Data; namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.PresentationObjects { @@ -42,11 +44,13 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); - Assert.AreSame(failureMechanism, context.WrappedData); + Assert.IsInstanceOf>>(context); + Assert.AreSame(failureMechanism.HydraulicBoundaryLocations, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); mockRepository.VerifyAll(); } @@ -57,7 +61,7 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - TestDelegate call = () => new HydraulicBoundariesGroupContext(failureMechanism, null); + TestDelegate call = () => new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, null); // Assert var paramName = Assert.Throws(call).ParamName; Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r8a90c409545ce1b48e018d3b5d6b5982dbef926f -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 8a90c409545ce1b48e018d3b5d6b5982dbef926f) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -55,7 +55,7 @@ [TestFixture] public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest { - private const int contextMenuRunDesignWaterLevelCalculationsIndex = 0; + private const int contextMenuRunDesignWaterLevelCalculationsIndex = 1; private MockRepository mockRepository; private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); @@ -89,6 +89,7 @@ Assert.IsNull(info.CanDrop); Assert.IsNull(info.CanInsert); Assert.IsNull(info.OnDrop); + Assert.IsNull(info.ForeColor); } } @@ -153,6 +154,8 @@ assessmentSectionMock); var menuBuilder = mockRepository.StrictMock(); + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); @@ -183,6 +186,7 @@ var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); + viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); using (var treeViewControl = new TreeViewControl()) { @@ -212,16 +216,21 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl)) { // Assert - Assert.AreEqual(3, menu.Items.Count); + Assert.AreEqual(5, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, 0, + CoreCommonGuiResources.Open, + CoreCommonGuiResources.Open_ToolTip, + CoreCommonGuiResources.OpenIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, + 2, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All, Resources.GrassCoverErosionOutwardsWaterLevelLocation_No_HRD_To_Calculate, RingtoetsCommonFormsResources.CalculateAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, - 2, + 4, CoreCommonGuiResources.Properties, CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesHS, @@ -230,6 +239,7 @@ CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[1], + menu.Items[3], }, typeof(ToolStripSeparator)); } } @@ -248,6 +258,7 @@ var importCommandHandler = mockRepository.Stub(); var exportCommandHandler = mockRepository.Stub(); var viewCommandsHandler = mockRepository.Stub(); + viewCommandsHandler.Stub(vch => vch.CanOpenViewFor(null)).IgnoreArguments().Return(true); using (var treeViewControl = new TreeViewControl()) { @@ -277,15 +288,20 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl)) { // Assert - Assert.AreEqual(3, menu.Items.Count); + Assert.AreEqual(5, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, 0, + CoreCommonGuiResources.Open, + CoreCommonGuiResources.Open_ToolTip, + CoreCommonGuiResources.OpenIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, + 2, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All_ToolTip, RingtoetsCommonFormsResources.CalculateAllIcon); TestHelper.AssertContextMenuStripContainsItem(menu, - 2, + 4, CoreCommonGuiResources.Properties, CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesHS, @@ -294,6 +310,7 @@ CollectionAssert.AllItemsAreInstancesOfType(new[] { menu.Items[1], + menu.Items[3], }, typeof(ToolStripSeparator)); } } @@ -302,61 +319,6 @@ } [Test] - public void ForeColor_ContextHasLocationsData_ReturnControlText() - { - // Setup - var assessmentSectionMock = mockRepository.Stub(); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 0, 0); - HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase - { - Locations = - { - hydraulicBoundaryLocation - } - }; - assessmentSectionMock.HydraulicBoundaryDatabase = database; - mockRepository.ReplayAll(); - var locations = new ObservableList - { - hydraulicBoundaryLocation - }; - var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(locations, assessmentSectionMock); - using (var plugin = new GrassCoverErosionOutwardsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - - // Call - Color color = info.ForeColor(context); - - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); - } - mockRepository.VerifyAll(); - } - - [Test] - public void ForeColor_ContextHasNoLocationsData_ReturnGrayText() - { - // Setup - var assessmentSectionMock = mockRepository.Stub(); - mockRepository.ReplayAll(); - var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext( - new ObservableList(), - assessmentSectionMock); - using (var plugin = new GrassCoverErosionOutwardsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - - // Call - Color color = info.ForeColor(context); - - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); - } - mockRepository.VerifyAll(); - } - - [Test] public void CalculateDesignWaterLevelsFromContextMenu_Always_SendsRightInputToCalculationService() { // Setup Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rf52ef19a25b70e103b1ca6bc5f84021b68138f41 -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision f52ef19a25b70e103b1ca6bc5f84021b68138f41) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -200,7 +200,9 @@ Assert.AreSame(failureMechanism, commentContext.WrappedData); var hydraulicBoundariesGroupContext = (HydraulicBoundariesGroupContext) children[1]; - Assert.AreSame(failureMechanism, hydraulicBoundariesGroupContext.WrappedData); + Assert.AreSame(failureMechanism.HydraulicBoundaryLocations, hydraulicBoundariesGroupContext.WrappedData); + Assert.AreSame(failureMechanism, hydraulicBoundariesGroupContext.FailureMechanism); + Assert.AreSame(assessmentSection, hydraulicBoundariesGroupContext.AssessmentSection); var outputsFolder = (CategoryTreeFolder) children[2]; Assert.AreEqual("Oordeel", outputsFolder.Name); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r538841777d95e5ccf83651d5d67002453ec750bc -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 538841777d95e5ccf83651d5d67002453ec750bc) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextTreeNodeInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -86,6 +86,7 @@ Assert.IsNull(info.CanDrop); Assert.IsNull(info.CanInsert); Assert.IsNull(info.OnDrop); + Assert.IsNull(info.ForeColor); } } @@ -301,62 +302,6 @@ } [Test] - public void ForeColor_ContextHasLocationsData_ReturnControlText() - { - // Setup - var assessmentSectionMock = mockRepository.Stub(); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "", 0, 0); - HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase - { - Locations = - { - hydraulicBoundaryLocation - } - }; - assessmentSectionMock.HydraulicBoundaryDatabase = database; - mockRepository.ReplayAll(); - var locations = new ObservableList - { - hydraulicBoundaryLocation - }; - var context = new GrassCoverErosionOutwardsWaveHeightLocationsContext(locations, assessmentSectionMock); - - using (var plugin = new GrassCoverErosionOutwardsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - - // Call - Color color = info.ForeColor(context); - - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); - } - mockRepository.VerifyAll(); - } - - [Test] - public void ForeColor_ContextHasNoLocationsData_ReturnGrayText() - { - // Setup - var assessmentSectionMock = mockRepository.Stub(); - mockRepository.ReplayAll(); - var context = new GrassCoverErosionOutwardsWaveHeightLocationsContext( - new ObservableList(), - assessmentSectionMock); - - using (var plugin = new GrassCoverErosionOutwardsPlugin()) - { - TreeNodeInfo info = GetInfo(plugin); - // Call - Color color = info.ForeColor(context); - - // Assert - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); - } - mockRepository.VerifyAll(); - } - - [Test] [RequiresSTA] public void GivenHydraulicBoundaryLocationThatFails_CalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() { Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r63b14648b4633ab7f052e91570ebb24c6aabb82b -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (.../HydraulicBoundariesGroupContextTreeNodeInfoTest.cs) (revision 63b14648b4633ab7f052e91570ebb24c6aabb82b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (.../HydraulicBoundariesGroupContextTreeNodeInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -31,6 +31,7 @@ using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.Plugin; +using Ringtoets.HydraRing.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.TreeNodeInfos @@ -87,7 +88,7 @@ var assessmentSectionMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call string nodeText = info.Text(context); @@ -103,7 +104,7 @@ var assessmentSectionMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call Image icon = info.Image(context); @@ -120,7 +121,7 @@ { var assessmentSectionMock = mockRepository.StrictMock(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); var menuBuilder = mockRepository.StrictMock(); menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder); @@ -145,18 +146,35 @@ } [Test] - public void ChildNodeObjects_Always_ReturnChildDataNodes() + public void ChildNodeObjects_NoHydraulicBoundaryDatabaseSet_ReturnNoChildNodes() { // Setup - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); // Call object[] children = info.ChildNodeObjects(context).ToArray(); // Assert + Assert.AreEqual(0, children.Length); + } + + [Test] + public void ChildNodeObjects_HydraulicBoundaryDatabaseSet_ReturnChildDataNodes() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert Assert.AreEqual(3, children.Length); var waterLevelHydraulicBoundaryLocationsContext = (GrassCoverErosionOutwardsDesignWaterLevelLocationsContext) children[0]; Assert.AreSame(failureMechanism.HydraulicBoundaryLocations, waterLevelHydraulicBoundaryLocationsContext.WrappedData); @@ -169,5 +187,38 @@ var waveConditionsCalculationGroupContext = (GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext) children[2]; Assert.AreSame(failureMechanism.WaveConditionsCalculationGroup, waveConditionsCalculationGroupContext.WrappedData); } + + [Test] + public void ForeColor_NoHydraulicBoundaryDatabaseSet_ReturnGrayText() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + } + + [Test] + public void ForeColor_HydraulicBoundaryDatabaseSet_ReturnControlColor() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new HydraulicBoundariesGroupContext(failureMechanism.HydraulicBoundaryLocations, failureMechanism, assessmentSectionMock); + + // Call + Color color = info.ForeColor(context); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -r90de5f60de0a152b946e686873ffb15cae3a7038 -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs) (revision 90de5f60de0a152b946e686873ffb15cae3a7038) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/ViewInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewInfoTest.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -30,6 +30,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.Forms.Properties; using Ringtoets.GrassCoverErosionOutwards.Forms.Views; @@ -135,6 +136,61 @@ } [Test] + public void CloseViewForData_ForMatchingFailureMechanismContext_ReturnsTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var grassCoverErosionOutwardsFailureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext( + new GrassCoverErosionOutwardsFailureMechanism(), + assessmentSection); + + using (var view = new GrassCoverErosionOutwardsDesignWaterLevelLocationsView()) + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + var info = GetInfo(plugin); + view.AssessmentSection = assessmentSection; + + // Call + var closeForData = info.CloseForData(view, grassCoverErosionOutwardsFailureMechanismContext); + + // Assert + Assert.IsTrue(closeForData); + } + mocks.VerifyAll(); + } + + [Test] + public void CloseViewForData_ForNonMatchingFailureMechanismContext_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSectionA = mocks.Stub(); + var assessmentSectionB = mocks.Stub(); + mocks.ReplayAll(); + + var grassCoverErosionOutwardsFailureMechanismContext = new GrassCoverErosionOutwardsFailureMechanismContext( + new GrassCoverErosionOutwardsFailureMechanism(), + assessmentSectionB); + + using (var view = new GrassCoverErosionOutwardsDesignWaterLevelLocationsView()) + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + var info = GetInfo(plugin); + view.AssessmentSection = assessmentSectionA; + + // Call + var closeForData = info.CloseForData(view, grassCoverErosionOutwardsFailureMechanismContext); + + // Assert + Assert.IsFalse(closeForData); + } + mocks.VerifyAll(); + } + + [Test] public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingSemiProbabilisticCalculationService.cs =================================================================== diff -u -ref2c6cb7afd29e17ada49f5a18b9e21968122232 -rb96f2e7a668c663c44150fcc3045edebb3ad56e9 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingSemiProbabilisticCalculationService.cs (.../PipingSemiProbabilisticCalculationService.cs) (revision ef2c6cb7afd29e17ada49f5a18b9e21968122232) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingSemiProbabilisticCalculationService.cs (.../PipingSemiProbabilisticCalculationService.cs) (revision b96f2e7a668c663c44150fcc3045edebb3ad56e9) @@ -41,8 +41,6 @@ private readonly double constantB; private readonly double assessmentSectionLength; private readonly double upliftCriticalSafetyFactor; - private readonly double heaveNormDependentFactor; - private readonly double sellmeijerNormDependentFactor; private readonly double contribution; // Intermediate results