Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r17cebf7b5ba4bd3b27d41ad322a18f2c50f4d731 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 17cebf7b5ba4bd3b27d41ad322a18f2c50f4d731) @@ -128,12 +128,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); @@ -146,8 +146,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(); @@ -156,12 +156,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(); @@ -171,11 +171,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] @@ -184,10 +184,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(); @@ -228,10 +228,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(); @@ -288,11 +288,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()) @@ -323,13 +323,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(); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -368,13 +368,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()) @@ -417,12 +417,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 = @@ -431,63 +428,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(); @@ -518,7 +467,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_SetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -530,18 +479,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(); @@ -559,14 +504,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); } @@ -594,16 +539,12 @@ }; var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var nodeData = new ClosingStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -614,7 +555,7 @@ mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; // Call using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) @@ -632,17 +573,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", @@ -663,26 +597,26 @@ 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.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + 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; - plugin.Gui = guiMock; DialogBoxHandler = (name, wnd) => @@ -724,12 +658,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", @@ -750,13 +678,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()) { @@ -765,8 +695,6 @@ mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; - plugin.Gui = guiMock; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(groupContext, null, treeViewControl)) @@ -794,17 +722,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()) { @@ -814,7 +742,7 @@ mocks.ReplayAll(); group.Children.Add(calculationGroup); - nodeData.Attach(observerMock); + nodeData.Attach(observer); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { @@ -841,16 +769,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()) { @@ -860,7 +788,7 @@ mocks.ReplayAll(); group.Children.Add(calculation); - nodeData.Attach(observerMock); + nodeData.Attach(observer); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { @@ -886,7 +814,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); ClosingStructure structure1 = new TestClosingStructure("Structure 1"); ClosingStructure structure2 = new TestClosingStructure("Structure 2"); @@ -902,7 +830,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -944,7 +872,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); ClosingStructure structure1 = new TestClosingStructure("Structure 1"); ClosingStructure structure2 = new TestClosingStructure("Structure 2"); @@ -960,7 +888,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1000,7 +928,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var existingCalculationName = "Closing structure"; ClosingStructure closingStructure = new TestClosingStructure(existingCalculationName); @@ -1025,7 +953,7 @@ var nodeData = new ClosingStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub();