Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r82bd489a2b49af2c1cd898b7944b3c4f5db8a808 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 82bd489a2b49af2c1cd898b7944b3c4f5db8a808) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -193,14 +193,8 @@ }; } - private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, - ClosingStructuresFailureMechanism failureMechanism) + private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection) { - if (!failureMechanism.Sections.Any()) - { - return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported; - } - return HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase); } @@ -391,7 +385,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInFailureMechanism(ClosingStructuresFailureMechanismContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.Parent, context.WrappedData); + return ValidateAllDataAvailableAndGetErrorMessage(context.Parent); } private void CalculateAll(ClosingStructuresFailureMechanismContext context) @@ -536,7 +530,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessage(ClosingStructuresCalculationGroupContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private void CalculateAll(CalculationGroup group, ClosingStructuresCalculationGroupContext context) @@ -634,7 +628,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculation(ClosingStructuresCalculationContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private static void CalculationContextOnNodeRemoved(ClosingStructuresCalculationContext context, object parentData) Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd69cf89498b4f926407d0261a747a4a7a8d37e62 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision d69cf89498b4f926407d0261a747a4a7a8d37e62) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -226,9 +226,9 @@ { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculation = new StructuresCalculation(); - var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -240,20 +240,20 @@ 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, "&Valideren", - "Er is geen vakindeling geïmporteerd.", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", RingtoetsCommonFormsResources.ValidateIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateIndex, "Be&rekenen", - "Er is geen vakindeling geïmporteerd.", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", RingtoetsCommonFormsResources.CalculateIcon, false); @@ -267,55 +267,12 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism(); var assessmentSectionStub = mocks.Stub(); var calculation = new StructuresCalculation(); - - var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); - - 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, - "Be&rekenen", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.CalculateIcon, - false); - - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, - "&Valideren", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.ValidateIcon, - false); - } - } - } - - [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() - { - // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - - var assessmentSectionStub = mocks.Stub(); - - var calculation = new StructuresCalculation(); var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -349,16 +306,11 @@ public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var calculation = new StructuresCalculation(); + var failureMechanism = new ClosingStructuresFailureMechanism(); var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -376,14 +328,14 @@ ToolStripItem calculateContextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; Assert.AreEqual("Be&rekenen", calculateContextMenuItem.Text); - StringAssert.Contains(string.Format("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. {0}", ""), calculateContextMenuItem.ToolTipText); + StringAssert.Contains($"Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", calculateContextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateIcon, calculateContextMenuItem.Image); Assert.IsFalse(calculateContextMenuItem.Enabled); ToolStripItem validateContextMenuItem = contextMenu.Items[contextMenuValidateIndex]; Assert.AreEqual("&Valideren", validateContextMenuItem.Text); - StringAssert.Contains(string.Format("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. {0}", ""), validateContextMenuItem.ToolTipText); + StringAssert.Contains($"Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", validateContextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateIcon, validateContextMenuItem.Image); Assert.IsFalse(validateContextMenuItem.Enabled); } @@ -402,16 +354,11 @@ Version = "1.0" }; - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new StructuresCalculation(); + var failureMechanism = new ClosingStructuresFailureMechanism(); var nodeData = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -444,14 +391,14 @@ { // Given var mainWindow = mocks.Stub(); - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); + { + new Point2D(1, 2), + new Point2D(3, 4) + }); var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.AddSection(section); @@ -466,10 +413,10 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - 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.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); var initialOutput = new ProbabilityAssessmentOutput(double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); var calculation = new TestClosingStructuresCalculation @@ -481,7 +428,7 @@ } }; - var calculationContext = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var calculationContext = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -492,7 +439,7 @@ plugin.Gui = guiMock; - calculation.Attach(observerMock); + calculation.Attach(observer); DialogBoxHandler = (name, wnd) => { @@ -507,16 +454,16 @@ // Then TestHelper.AssertLogMessages(action, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(6, msgs.Length); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); - StringAssert.StartsWith("Betrouwbaarheid sluiting kunstwerk berekening is uitgevoerd op de tijdelijke locatie", msgs[3]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); - StringAssert.StartsWith(string.Format("Uitvoeren van '{0}' is gelukt.", calculation.Name), msgs[5]); - }); + { + var msgs = messages.ToArray(); + Assert.AreEqual(6, msgs.Length); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' gestart om: ", msgs[0]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' beëindigd om: ", msgs[1]); + StringAssert.StartsWith($"Berekening van '{calculation.Name}' gestart om: ", msgs[2]); + StringAssert.StartsWith("Betrouwbaarheid sluiting kunstwerk berekening is uitgevoerd op de tijdelijke locatie", msgs[3]); + StringAssert.StartsWith($"Berekening van '{calculation.Name}' beëindigd om: ", msgs[4]); + StringAssert.StartsWith($"Uitvoeren van '{calculation.Name}' is gelukt.", msgs[5]); + }); Assert.AreNotSame(initialOutput, calculation.Output); } @@ -527,17 +474,6 @@ public void GivenCalculationWithNonExistingFilePath_WhenValidatingFromContextMenu_ThenLogMessagesAdded() { // Given - var observerMock = mocks.StrictMock(); - - var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); - - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(section); - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.0, 1.1); @@ -548,7 +484,8 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new TestClosingStructuresCalculation { @@ -558,33 +495,33 @@ } }; - var calculationContext = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var observer = mocks.StrictMock(); + calculation.Attach(observer); + var failureMechanism = new ClosingStructuresFailureMechanism(); + var calculationContext = new ClosingStructuresCalculationContext(calculation, failureMechanism, assessmentSection); + using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(g => g.Get(calculationContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - plugin.Gui = guiMock; - calculation.Attach(observerMock); - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(calculationContext, null, treeViewControl)) { // When Action action = () => contextMenuStrip.Items[contextMenuValidateIndex].PerformClick(); // Then TestHelper.AssertLogMessages(action, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(2, msgs.Length); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); - }); + { + var msgs = messages.ToArray(); + Assert.AreEqual(2, msgs.Length); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' gestart om: ", msgs[0]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' beëindigd om: ", msgs[1]); + }); } } } @@ -596,22 +533,22 @@ var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); var elementToBeRemoved = new StructuresCalculation(); - var observerMock = mocks.StrictMock(); - var assessmentSectionStub = mocks.Stub(); + var observer = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var calculationContext = new ClosingStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new ClosingStructuresCalculationGroupContext(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)); @@ -632,22 +569,22 @@ var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); var elementToBeRemoved = new StructuresCalculation(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculationContext = new ClosingStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); mocks.ReplayAll(); group.Children.Add(elementToBeRemoved); failureMechanism.AddSection(new FailureMechanismSection("section", new[] - { - new Point2D(0, 0) - })); + { + new Point2D(0, 0) + })); ClosingStructuresFailureMechanismSectionResult result = failureMechanism.SectionResults.First(); result.Calculation = elementToBeRemoved; Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -127,12 +127,12 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); mocks.ReplayAll(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var children = info.ChildNodeObjects(groupContext); @@ -145,8 +145,8 @@ public void ChildNodeObjects_GroupWithMixedContents_ReturnChildren() { // Setup - var assessmentSectionStub = mocks.Stub(); - var calculationItemMock = mocks.Stub(); + var assessmentSection = mocks.Stub(); + var calculationItem = mocks.Stub(); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -155,12 +155,12 @@ var childCalculation = new StructuresCalculation(); group.Children.Add(childGroup); - group.Children.Add(calculationItemMock); + group.Children.Add(calculationItem); group.Children.Add(childCalculation); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var children = info.ChildNodeObjects(groupContext).ToArray(); @@ -170,11 +170,11 @@ var calculationGroupContext = (ClosingStructuresCalculationGroupContext) children[0]; Assert.AreSame(childGroup, calculationGroupContext.WrappedData); Assert.AreSame(failureMechanism, calculationGroupContext.FailureMechanism); - Assert.AreSame(assessmentSectionStub, calculationGroupContext.AssessmentSection); - Assert.AreSame(calculationItemMock, children[1]); + Assert.AreSame(assessmentSection, calculationGroupContext.AssessmentSection); + Assert.AreSame(calculationItem, children[1]); var calculationContext = (ClosingStructuresCalculationContext) children[2]; Assert.AreSame(childCalculation, calculationContext.WrappedData); - Assert.AreSame(assessmentSectionStub, calculationContext.AssessmentSection); + Assert.AreSame(assessmentSection, calculationContext.AssessmentSection); } [Test] @@ -183,10 +183,10 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilderMock = mocks.StrictMock(); @@ -205,7 +205,7 @@ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); - + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); @@ -231,10 +231,10 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -291,11 +291,11 @@ var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.ClosingStructures.Add(new TestClosingStructure()); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -326,13 +326,13 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentGroupContext = new ClosingStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilderMock = mocks.StrictMock(); using (mocks.Ordered()) @@ -374,13 +374,13 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentGroupContext = new ClosingStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -423,12 +423,9 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var group = new CalculationGroup { Children = @@ -437,63 +434,15 @@ } }; - var nodeData = new ClosingStructuresCalculationGroupContext(group, - failureMechanism, - assessmentSectionStub); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, - "Alles be&rekenen", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.CalculateAllIcon, - false); - - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, - "Alles &valideren", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.ValidateAllIcon, - false); - } - } - } - - [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() - { - // Setup - var group = new CalculationGroup - { - Children = - { - new StructuresCalculation() - } - }; - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = null; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = null; var nodeData = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -524,7 +473,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -536,18 +485,14 @@ }; var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var nodeData = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -565,14 +510,14 @@ ToolStripItem calculatAllContextMenuItem = contextMenu.Items[contextMenuCalculateAllIndexRootGroup]; Assert.AreEqual("Alles be&rekenen", calculatAllContextMenuItem.Text); - StringAssert.Contains(string.Format("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. {0}", ""), calculatAllContextMenuItem.ToolTipText); + StringAssert.Contains($"Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", calculatAllContextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, calculatAllContextMenuItem.Image); Assert.IsFalse(calculatAllContextMenuItem.Enabled); ToolStripItem validateAllContextMenuItem = contextMenu.Items[contextMenuValidateAllIndexRootGroup]; Assert.AreEqual("Alles &valideren", validateAllContextMenuItem.Text); - StringAssert.Contains(string.Format("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. {0}", ""), validateAllContextMenuItem.ToolTipText); + StringAssert.Contains($"Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", validateAllContextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateAllIcon, validateAllContextMenuItem.Image); Assert.IsFalse(validateAllContextMenuItem.Enabled); } @@ -600,10 +545,6 @@ }; var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); var assessmentSectionStub = mocks.Stub(); @@ -638,17 +579,10 @@ public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() { // Setup - var mainWindowStub = mocks.Stub(); + var mainWindow = mocks.Stub(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new ClosingStructuresFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(2, 2) - })); - failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation { Name = "A", @@ -669,25 +603,25 @@ string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - var hydraulicBoundaryDatabaseStub = mocks.Stub(); - hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + var hydraulicBoundaryDatabase = mocks.Stub(); + hydraulicBoundaryDatabase.FilePath = validFilePath; - 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)); var groupContext = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); - guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + guiMock.Expect(g => g.MainWindow).Return(mainWindow); guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; plugin.Gui = guiMock; @@ -730,12 +664,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new ClosingStructuresFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - })); - failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation { Name = "A", @@ -756,13 +684,15 @@ string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - var hydraulicBoundaryDatabaseStub = mocks.Stub(); - hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + var hydraulicBoundaryDatabase = mocks.Stub(); + hydraulicBoundaryDatabase.FilePath = validFilePath; - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var groupContext = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -771,8 +701,6 @@ mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; - plugin.Gui = guiMock; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(groupContext, null, treeViewControl)) @@ -800,17 +728,17 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var nodeData = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var calculationGroup = new CalculationGroup { Name = "Nieuwe map" }; - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); using (var treeViewControl = new TreeViewControl()) { @@ -820,7 +748,7 @@ mocks.ReplayAll(); group.Children.Add(calculationGroup); - nodeData.Attach(observerMock); + nodeData.Attach(observer); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { @@ -847,16 +775,16 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new CalculationGroup(); var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var nodeData = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var calculation = new StructuresCalculation { Name = "Nieuwe berekening" }; - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); using (var treeViewControl = new TreeViewControl()) { @@ -866,7 +794,7 @@ mocks.ReplayAll(); group.Children.Add(calculation); - nodeData.Attach(observerMock); + nodeData.Attach(observer); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { @@ -892,7 +820,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); ClosingStructure structure1 = new TestClosingStructure("Structure 1"); ClosingStructure structure2 = new TestClosingStructure("Structure 2"); @@ -908,7 +836,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -950,7 +878,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); ClosingStructure structure1 = new TestClosingStructure("Structure 1"); ClosingStructure structure2 = new TestClosingStructure("Structure 2"); @@ -966,7 +894,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1006,7 +934,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var existingCalculationName = "Closing structure"; ClosingStructure closingStructure = new TestClosingStructure(existingCalculationName); @@ -1031,7 +959,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/TreeNodeInfos/ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -23,7 +23,6 @@ using System.IO; using System.Linq; using System.Windows.Forms; -using Core.Common.Base.Geometry; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.Commands; @@ -424,57 +423,13 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new ClosingStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionMock = mocksRepository.StrictMock(); - var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - - mocksRepository.ReplayAll(); - - plugin.Gui = guiMock; - - // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, - "Alles be&rekenen", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.CalculateAllIcon, - false); - - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, - "Alles &valideren", - "Er is geen vakindeling geïmporteerd.", - RingtoetsCommonFormsResources.ValidateAllIcon, - false); - } - } - } - - [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() - { - // Setup - var guiMock = mocksRepository.StrictMock(); - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionMock = mocksRepository.Stub(); var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); @@ -508,21 +463,17 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionMock = mocksRepository.Stub(); - assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -560,10 +511,6 @@ // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); @@ -574,10 +521,10 @@ Version = "1.0" }; - var assessmentSectionMock = mocksRepository.Stub(); - assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var nodeData = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -614,14 +561,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new ClosingStructuresFailureMechanism(); - - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(2, 2) - }); - failureMechanism.AddSection(section); - failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation { Name = "A", @@ -697,11 +636,6 @@ { // Setup var failureMechanism = new ClosingStructuresFailureMechanism(); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - }); - failureMechanism.AddSection(section); failureMechanism.CalculationsGroup.Children.Add(new TestClosingStructuresCalculation { Name = "A", Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r46a26eb2df5ad4a02467e43d8101027d5d8d42a5 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 46a26eb2df5ad4a02467e43d8101027d5d8d42a5) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -200,13 +200,8 @@ assessmentSection)).ToArray()); } - private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, GrassCoverErosionInwardsFailureMechanism failureMechanism) + private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection) { - if (!failureMechanism.Sections.Any()) - { - return RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported; - } - return HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase); } @@ -426,7 +421,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInFailureMechanism(GrassCoverErosionInwardsFailureMechanismContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.Parent, context.WrappedData); + return ValidateAllDataAvailableAndGetErrorMessage(context.Parent); } private static void ValidateAll(GrassCoverErosionInwardsFailureMechanismContext context) @@ -594,7 +589,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInGroup(GrassCoverErosionInwardsCalculationGroupContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private static void ValidateAll(GrassCoverErosionInwardsCalculationGroupContext context) @@ -659,7 +654,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculation(GrassCoverErosionInwardsCalculationContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private static void Validate(GrassCoverErosionInwardsCalculationContext context) Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -176,9 +176,9 @@ // Setup var guiMock = mocks.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSectionStub = mocks.Stub(); var calculation = new GrassCoverErosionInwardsCalculation(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionStub); var menuBuilderMock = mocks.Stub(); using (mocks.Ordered()) @@ -267,51 +267,14 @@ } [Test] - public void ContextMenuStrip_NoSections_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_NoDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var calculation = new GrassCoverErosionInwardsCalculation(); - - var nodeData = new GrassCoverErosionInwardsCalculationContext(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_SectionsSetNoDatabase_ContextMenuItemPerformCalculationDisabledAndTooltipSet() - { - // Setup - var guiMock = mocks.StrictMock(); - - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -336,21 +299,16 @@ } [Test] - public void ContextMenuStrip_SectionsSetDatabaseNotValid_ContextMenuItemPerformCalculationDisabledAndTooltipSet() + public void ContextMenuStrip_DatabaseNotValid_ContextMenuItemPerformCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionMock = mocks.StrictMock(); assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase()); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); using (var treeViewControl = new TreeViewControl()) @@ -367,16 +325,16 @@ // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateIndex]; - Assert.AreEqual(RingtoetsCommonFormsResources.Calculate, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServiceResources.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); } } } [Test] - public void ContextMenuStrip_SectionsAndDatabaseSet_ContextMenuItemPerformCalculationEnabled() + public void ContextMenuStrip_DatabaseSet_ContextMenuItemPerformCalculationEnabled() { // Setup var guiMock = mocks.StrictMock(); @@ -389,16 +347,11 @@ Version = "1.0" }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionMock = mocks.StrictMock(); assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); using (var treeViewControl = new TreeViewControl()) @@ -414,59 +367,22 @@ { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateIndex, - RingtoetsCommonFormsResources.Calculate, - RingtoetsCommonFormsResources.Calculate_ToolTip, + "Be&rekenen", + "Voer deze berekening uit.", RingtoetsCommonFormsResources.CalculateIcon); } } } [Test] - public void ContextMenuStrip_NoSections_ContextMenuItemValidateCalculationDisabledAndTooltipSet() - { - // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); - var calculation = new GrassCoverErosionInwardsCalculation(); - - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); - 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 (var 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_SectionsSetNoDatabase_ContextMenuItemValidateCalculationDisabledAndTooltipSet() { // Setup var guiMock = mocks.StrictMock(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -496,16 +412,11 @@ // Setup var guiMock = mocks.StrictMock(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionMock = mocks.StrictMock(); assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase()); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); using (var treeViewControl = new TreeViewControl()) @@ -521,9 +432,9 @@ { // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateIndex]; - - Assert.AreEqual(RingtoetsCommonFormsResources.Validate, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServiceResources.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); } @@ -544,16 +455,11 @@ Version = "1.0" }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionMock = mocks.StrictMock(); assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); var calculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSectionMock); using (var treeViewControl = new TreeViewControl()) @@ -569,8 +475,8 @@ { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateIndex, - RingtoetsCommonFormsResources.Validate, - RingtoetsCommonFormsResources.Validate_ToolTip, + "&Valideren", + "Valideer de invoer voor deze berekening.", RingtoetsCommonFormsResources.ValidateIcon); } } @@ -585,14 +491,7 @@ var observerMock = mocks.StrictMock(); observerMock.Expect(o => o.UpdateObserver()); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(section); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); @@ -671,14 +570,7 @@ var gui = mocks.StrictMock(); var observerMock = mocks.StrictMock(); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(section); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -49,8 +49,8 @@ using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using GrassCoverErosionInwardsPluginResources = Ringtoets.GrassCoverErosionInwards.Plugin.Properties.Resources; -using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; + namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.TreeNodeInfos { [TestFixture] @@ -326,13 +326,13 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); var groupContext = new GrassCoverErosionInwardsCalculationGroupContext(group, failureMechanism, - assessmentSectionMock); + assessmentSection); var parentGroupContext = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -373,14 +373,64 @@ } } } - + [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup + var group = new CalculationGroup + { + Children = + { + new GrassCoverErosionInwardsCalculation() + } + }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + var assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(null); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + + var applicationFeatureCommandHandlerStub = mocks.Stub(); + var importHandlerMock = mocks.StrictMock(); + var exportHandlerMock = mocks.StrictMock(); + var viewCommandsHandlerMock = mocks.StrictMock(); + + using (var treeViewControl = new TreeViewControl()) + { + var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandlerStub, + importHandlerMock, + exportHandlerMock, + viewCommandsHandlerMock, + nodeData, + treeViewControl); + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndexRootGroup, + "Alles be&rekenen", + "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", + RingtoetsCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup var group = new CalculationGroup { Children = @@ -389,6 +439,13 @@ } }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + var assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase()); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, failureMechanism, assessmentSectionMock); @@ -411,20 +468,72 @@ mocks.ReplayAll(); // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem calculateContextMenuItem = contextMenu.Items[contextMenuCalculateAllIndexRootGroup]; + Assert.AreEqual("Alles be&rekenen", calculateContextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt", calculateContextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, calculateContextMenuItem.Image); + Assert.IsFalse(calculateContextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var group = new CalculationGroup + { + Children = + { + new GrassCoverErosionInwardsCalculation() + } + }; + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + var assessmentSectionMock = mocks.StrictMock(); + assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + // Call using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, - RingtoetsCommonFormsResources.Calculate_all, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, - RingtoetsCommonFormsResources.CalculateAllIcon, - false); + "Alles be&rekenen", + "Voer alle berekeningen binnen deze berekeningsmap uit.", + RingtoetsCommonFormsResources.CalculateAllIcon); } } } + [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetNoHydraulicBoundaryDatabase_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -436,10 +545,6 @@ }; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); var assessmentSectionMock = mocks.StrictMock(); @@ -470,17 +575,17 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndexRootGroup, - "Alles be&rekenen", + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", "Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", - RingtoetsCommonFormsResources.CalculateAllIcon, + RingtoetsCommonFormsResources.ValidateAllIcon, false); } } } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllDisabledAndTooltipSet() + public void ContextMenuStrip_SetHydraulicBoundaryDatabaseNotValid_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -492,10 +597,6 @@ }; var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); var assessmentSectionMock = mocks.StrictMock(); @@ -526,18 +627,18 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndexRootGroup]; + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateAllIndexRootGroup]; - Assert.AreEqual(RingtoetsCommonFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.AreEqual("Alles &valideren", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); } } } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemCalculateAllEnabled() + public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemValidateAllEnabled() { // Setup var group = new CalculationGroup @@ -582,14 +683,15 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, - RingtoetsCommonFormsResources.Calculate_all, - RingtoetsCommonFormsResources.CalculationGroup_CalculateAll_ToolTip, - RingtoetsCommonFormsResources.CalculateAllIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + "Alles &valideren", + "Valideer alle berekeningen binnen deze berekeningsmap.", + RingtoetsCommonFormsResources.ValidateAllIcon); } } } + [Test] public void ContextMenuStrip_FailureMechanismWithoutDikeProfiles_ContextMenuItemGenerateCalculationsDisabledAndTooltipSet() { @@ -665,12 +767,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - })); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { Name = "A", @@ -738,13 +834,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1.1, 1.1) - })); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { Name = "A", @@ -875,10 +964,10 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new CalculationGroup(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSectionStub = mocks.Stub(); var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, failureMechanism, - assessmentSectionMock); + assessmentSectionStub); var calculationItem = new GrassCoverErosionInwardsCalculation { Name = "Nieuwe berekening" @@ -1034,7 +1123,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSectionStub = mocks.Stub(); const string existingCalculationName = "Dike profile"; DikeProfile dikeProfile = new TestDikeProfile(existingCalculationName); @@ -1059,7 +1148,7 @@ var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSectionStub); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 15fe8a0d6c08231dfa23bd58f84b6aa6adcba3e3) @@ -415,49 +415,11 @@ } [Test] - public void ContextMenuStrip_NoSections_ContextMenuItemCalculateAllDisabledAndTooltipSet() - { - // Setup - var guiMock = mocksRepository.StrictMock(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); - var assessmentSectionMock = mocksRepository.StrictMock(); - - var nodeData = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - - mocksRepository.ReplayAll(); - - plugin.Gui = guiMock; - - // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, - RingtoetsCommonFormsResources.Calculate_all, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, - RingtoetsCommonFormsResources.CalculateAllIcon, - false); - } - } - } - - [Test] public void ContextMenuStrip_SectionsSetNoDatabase_ContextMenuItemCalculateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); var assessmentSectionMock = mocksRepository.Stub(); @@ -492,10 +454,6 @@ // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); var assessmentSectionMock = mocksRepository.StrictMock(); @@ -518,8 +476,8 @@ // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; - Assert.AreEqual(RingtoetsCommonFormsResources.Calculate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); } @@ -532,10 +490,6 @@ // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); @@ -565,52 +519,19 @@ { // Assert TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, - RingtoetsCommonFormsResources.Calculate_all, - RingtoetsCommonFormsResources.Calculate_all_ToolTip, + "Alles be&rekenen", + "Voer alle berekeningen binnen dit toetsspoor uit.", RingtoetsCommonFormsResources.CalculateAllIcon); } } } [Test] - public void ContextMenuStrip_NoSections_ContextMenuItemValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoDatabase_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); - var assessmentSectionMock = mocksRepository.StrictMock(); - - var nodeData = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSectionMock); - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - - mocksRepository.ReplayAll(); - - plugin.Gui = guiMock; - - // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, - RingtoetsCommonFormsResources.Validate_all, - RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_failure_mechanism_sections_imported, - RingtoetsCommonFormsResources.ValidateAllIcon, - false); - } - } - } - - [Test] - public void ContextMenuStrip_SectionsSetNoDatabase_ContextMenuItemValidateAllDisabledAndTooltipSet() - { - // Setup - var guiMock = mocksRepository.StrictMock(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("test", new[] { new Point2D(0, 0) @@ -644,7 +565,7 @@ } [Test] - public void ContextMenuStrip_SectionsSetDatabaseNotValid_ContextMenuItemValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_DatabaseNotValid_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); @@ -675,24 +596,20 @@ // Assert ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateAllIndex]; - Assert.AreEqual(RingtoetsCommonFormsResources.Validate_all, contextMenuItem.Text); - StringAssert.Contains(string.Format(RingtoetsCommonServiceResources.Hydraulic_boundary_database_connection_failed_0_, ""), contextMenuItem.ToolTipText); + Assert.AreEqual("Alles &valideren", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", contextMenuItem.ToolTipText); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.ValidateAllIcon, contextMenuItem.Image); Assert.IsFalse(contextMenuItem.Enabled); } } } [Test] - public void ContextMenuStrip_SectionsAndDatabaseSet_ContextMenuItemValidateAllEnabled() + public void ContextMenuStripDatabaseSet_ContextMenuItemValidateAllEnabled() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); @@ -722,8 +639,8 @@ { // Assert TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, - RingtoetsCommonFormsResources.Validate_all, - RingtoetsCommonFormsResources.FailureMechanism_Validate_all_ToolTip, + "Alles &valideren", + "Valideer alle berekeningen binnen dit toetsspoor.", RingtoetsCommonFormsResources.ValidateAllIcon); } } @@ -738,14 +655,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(1.0, 1.0) - }); - failureMechanism.AddSection(section); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { Name = "A", @@ -826,13 +735,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - }); - failureMechanism.AddSection(section); - failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation { Name = "A",