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();