Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf2f7d22ee59276f5df1f83fd409899bd895ea163 -r020be8875c3ee16809e8af396307869029f12ba3 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision f2f7d22ee59276f5df1f83fd409899bd895ea163) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision 020be8875c3ee16809e8af396307869029f12ba3) @@ -113,12 +113,12 @@ [Test] public void ChildNodeObjects_CalculationWithoutOutput_ReturnCollectionWithEmptyOutputObject() { - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); mocks.ReplayAll(); var calculation = new StructuresCalculation(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); // Call var children = info.ChildNodeObjects(calculationContext).ToArray(); @@ -140,15 +140,15 @@ [Test] public void ChildNodeObjects_CalculationWithOutput_ReturnCollectionWithOutputObject() { - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); mocks.ReplayAll(); var calculation = new StructuresCalculation { Output = new ProbabilityAssessmentOutput(0, 0, 0, 0, 0) }; var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); // Call var children = info.ChildNodeObjects(calculationContext).ToArray(); @@ -173,9 +173,9 @@ // Setup var guiMock = mocks.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); var menuBuilderMock = mocks.StrictMock(); using (mocks.Ordered()) { @@ -192,7 +192,7 @@ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.Build()).Return(null); } - + using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilderMock); @@ -214,16 +214,16 @@ // Setup var guiMock = mocks.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - assessmentSectionMock.Stub(asm => asm.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + assessmentSection.Stub(asm => asm.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase { FilePath = validFilePath, Version = "random" @@ -238,7 +238,7 @@ })); // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionMock, treeViewControl)) + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // Assert Assert.AreEqual(11, menu.Items.Count); @@ -263,55 +263,19 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() { // Setup - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(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, - "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 guiMock = mocks.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.AddSection(new FailureMechanismSection("test", new[] { new Point2D(0, 0) })); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -345,16 +309,12 @@ // Setup var guiMock = mocks.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -385,7 +345,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationAndValidationEnabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationAndValidationEnabled() { // Setup var guiMock = mocks.StrictMock(); @@ -402,11 +362,11 @@ new Point2D(0, 0) })); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new StructuresCalculation(); - var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var nodeData = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -439,18 +399,9 @@ // Given var guiMock = mocks.StrictMock(); 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) - }); - - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - failureMechanism.AddSection(section); - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.0, 1.1); @@ -461,9 +412,10 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.Stub(a => a.Id).Return(string.Empty); - assessmentSectionStub.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); + var assessmentSection = mocks.Stub(); + assessmentSection.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 TestStabilityPointStructuresCalculation @@ -476,8 +428,10 @@ LoadSchematizationType = LoadSchematizationType.Linear } }; + calculation.Attach(observer); - var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -488,9 +442,6 @@ plugin.Gui = guiMock; - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - calculation.Attach(observerMock); - DialogBoxHandler = (name, wnd) => { // Expect an activity dialog which is automatically closed @@ -524,17 +475,8 @@ public void GivenCalculationWithNonExistingFilePath_WhenValidatingFromContextMenu_ThenLogMessagesAdded() { // Given - var observerMock = mocks.StrictMock(); + var observer = mocks.StrictMock(); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(1, 2), - new Point2D(3, 4) - }); - - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - failureMechanism.AddSection(section); - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.0, 1.1); @@ -557,7 +499,9 @@ LoadSchematizationType = LoadSchematizationType.Linear } }; + calculation.Attach(observer); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); var calculationContext = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionStub); using (var treeViewControl = new TreeViewControl()) @@ -569,8 +513,6 @@ plugin.Gui = guiMock; - calculation.Attach(observerMock); - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(calculationContext, null, treeViewControl)) { // When @@ -595,22 +537,22 @@ var group = new CalculationGroup(); var elementToBeRemoved = new StructuresCalculation(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var observerMock = mocks.StrictMock(); - var assessmentSectionStub = mocks.Stub(); + var observer = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var calculationContext = new StabilityPointStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new StabilityPointStructuresCalculationGroupContext(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)); @@ -631,13 +573,13 @@ var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var elementToBeRemoved = new StructuresCalculation(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var calculationContext = new StabilityPointStructuresCalculationContext(elementToBeRemoved, failureMechanism, - assessmentSectionStub); + assessmentSection); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); mocks.ReplayAll();