Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r020be8875c3ee16809e8af396307869029f12ba3 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 020be8875c3ee16809e8af396307869029f12ba3) @@ -48,7 +48,6 @@ using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; -using RingtoetsCommonServicesResources = Ringtoets.Common.Service.Properties.Resources; namespace Ringtoets.HeightStructures.Plugin.Test.TreeNodeInfos { @@ -218,9 +217,9 @@ // Setup var guiMock = mocks.StrictMock(); var failureMechanism = new HeightStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -232,80 +231,42 @@ plugin.Gui = guiMock; // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionStub, treeViewControl)) + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // Assert Assert.AreEqual(11, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateIndex, - RingtoetsCommonFormsResources.Validate, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, + "&Valideren", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", RingtoetsCommonFormsResources.ValidateIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateIndex, - RingtoetsCommonFormsResources.Calculate, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, + "Be&rekenen", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", RingtoetsCommonFormsResources.CalculateIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIndex, - RingtoetsCommonFormsResources.Clear_output, - RingtoetsCommonFormsResources.ClearOutput_No_output_to_clear, + "&Wis uitvoer...", + "Deze berekening heeft geen uitvoer om te wissen.", RingtoetsCommonFormsResources.ClearIcon, false); } } } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemPerformCalculationDisabledAndTooltipSet() - { - // Setup - var failureMechanism = new HeightStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); - var guiMock = mocks.StrictMock(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - - mocks.ReplayAll(); - - plugin.Gui = guiMock; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, - RingtoetsCommonFormsResources.Calculate, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, - RingtoetsCommonFormsResources.CalculateIcon, - false); - } - } - } - - [Test] public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -329,29 +290,23 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); plugin.Gui = guiMock; @@ -361,8 +316,8 @@ // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; - Assert.AreEqual(RingtoetsCommonFormsResources.Calculate, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServicesResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + Assert.AreEqual("Be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); } @@ -384,11 +339,6 @@ }; var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); var calculation = new StructuresCalculation(); @@ -409,61 +359,23 @@ { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, - RingtoetsCommonFormsResources.Calculate, - RingtoetsCommonFormsResources.Calculate_ToolTip, + "Be&rekenen", + "Voer deze berekening uit.", RingtoetsCommonFormsResources.CalculateIcon); } } } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemValidateCalculationDisabledAndTooltipSet() - { - // Setup - var failureMechanism = new HeightStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); - var guiMock = mocks.StrictMock(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - - mocks.ReplayAll(); - - plugin.Gui = guiMock; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, - RingtoetsCommonFormsResources.Validate, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, - RingtoetsCommonFormsResources.ValidateIcon, - false); - } - } - } - - [Test] public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemValidateCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -487,30 +399,24 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var assessmentSectionStub = mocks.Stub(); - + var failureMechanism = new HeightStructuresFailureMechanism(); var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - plugin.Gui = guiMock; // Call @@ -519,16 +425,16 @@ // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateIndex]; - Assert.AreEqual(RingtoetsCommonFormsResources.Validate, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServicesResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + Assert.AreEqual("&Valideren", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); } } } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemValidateCalculationEnabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemValidateCalculationEnabled() { // Setup var guiMock = mocks.StrictMock(); @@ -541,34 +447,28 @@ Version = "1.0" }; - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var failureMechanism = new HeightStructuresFailureMechanism(); + var nodeData = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - plugin.Gui = guiMock; // Call using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, - RingtoetsCommonFormsResources.Validate, - RingtoetsCommonFormsResources.Validate_ToolTip, + "&Valideren", + "Valideer de invoer voor deze berekening.", RingtoetsCommonFormsResources.ValidateIcon); } } @@ -580,8 +480,8 @@ // Given var gui = mocks.DynamicMock(); var mainWindow = mocks.DynamicMock(); - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); var section = new FailureMechanismSection("A", new[] { @@ -602,9 +502,10 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.Stub(a => a.Id).Return(string.Empty); - assessmentSectionStub.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var initialOutput = new ProbabilityAssessmentOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); var calculation = new TestHeightStructuresCalculation @@ -615,8 +516,9 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation } }; + calculation.Attach(observer); - var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -625,12 +527,8 @@ mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - plugin.Gui = gui; - calculation.Attach(observerMock); - DialogBoxHandler = (name, wnd) => { // Expect an activity dialog which is automatically closed @@ -665,19 +563,9 @@ { // Given var gui = mocks.DynamicMock(); - var observerMock = mocks.StrictMock(); + var observer = mocks.StrictMock(); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(section); - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.0, 1.1); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -686,7 +574,8 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new TestHeightStructuresCalculation { @@ -695,21 +584,19 @@ HydraulicBoundaryLocation = hydraulicBoundaryLocation } }; + calculation.Attach(observer); - var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var failureMechanism = new HeightStructuresFailureMechanism(); + var calculationContext = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { gui.Expect(g => g.Get(calculationContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - plugin.Gui = gui; - calculation.Attach(observerMock); - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(calculationContext, null, treeViewControl)) { // When @@ -734,22 +621,22 @@ var group = new CalculationGroup(); var failureMechanism = new HeightStructuresFailureMechanism(); var elementToBeRemoved = new StructuresCalculation(); - var observerMock = mocks.StrictMock(); - var assessmentSectionStub = mocks.Stub(); + var observer = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var calculationContext = new HeightStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new HeightStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); - observerMock.Expect(o => o.UpdateObserver()); + observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); group.Children.Add(elementToBeRemoved); group.Children.Add(new StructuresCalculation()); - group.Attach(observerMock); + group.Attach(observer); // Precondition Assert.IsTrue(info.CanRemove(calculationContext, groupContext)); @@ -770,13 +657,13 @@ var group = new CalculationGroup(); var failureMechanism = new HeightStructuresFailureMechanism(); var elementToBeRemoved = new StructuresCalculation(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculationContext = new HeightStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new HeightStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); mocks.ReplayAll();