Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r54fd939cf2a3d8f718dad28faa24373334d4cc2e -r847a54f246d108d48f712fef5e1b961523f2c453 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 54fd939cf2a3d8f718dad28faa24373334d4cc2e) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 847a54f246d108d48f712fef5e1b961523f2c453) @@ -261,13 +261,8 @@ #region Validation and Calculation - private static string ValidateAllDataAvailableAndGetErrorMessage(IAssessmentSection assessmentSection, StabilityPointStructuresFailureMechanism 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); } @@ -409,7 +404,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInFailureMechanism(StabilityPointStructuresFailureMechanismContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.Parent, context.WrappedData); + return ValidateAllDataAvailableAndGetErrorMessage(context.Parent); } private static void ValidateAll(StabilityPointStructuresFailureMechanismContext context) @@ -581,7 +576,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInGroup(StabilityPointStructuresCalculationGroupContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private static void ValidateAll(StabilityPointStructuresCalculationGroupContext context) @@ -644,7 +639,7 @@ private static string ValidateAllDataAvailableAndGetErrorMessageForCalculation(StabilityPointStructuresCalculationContext context) { - return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection, context.FailureMechanism); + return ValidateAllDataAvailableAndGetErrorMessage(context.AssessmentSection); } private void Calculate(StructuresCalculation calculation, StabilityPointStructuresCalculationContext context) Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r847a54f246d108d48f712fef5e1b961523f2c453 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision 847a54f246d108d48f712fef5e1b961523f2c453) @@ -114,12 +114,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(); @@ -141,15 +141,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(); @@ -174,9 +174,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(); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -212,16 +212,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" @@ -236,7 +236,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); @@ -261,55 +261,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()) { @@ -338,21 +302,17 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemPerformCalculationAndValidationDisabledAndTooltipSet() { // 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()) { @@ -383,7 +343,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationAndValidationEnabled() + public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemPerformCalculationAndValidationEnabled() { // Setup var guiMock = mocks.StrictMock(); @@ -400,11 +360,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()) { @@ -437,18 +397,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); @@ -459,9 +410,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 @@ -474,8 +426,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()) { @@ -485,10 +439,7 @@ mocks.ReplayAll(); plugin.Gui = guiMock; - - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - calculation.Attach(observerMock); - + DialogBoxHandler = (name, wnd) => { // Expect an activity dialog which is automatically closed @@ -522,17 +473,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); @@ -543,8 +485,8 @@ }; hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var calculation = new TestStabilityPointStructuresCalculation { @@ -555,8 +497,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()) { @@ -567,8 +511,6 @@ plugin.Gui = guiMock; - calculation.Attach(observerMock); - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(calculationContext, null, treeViewControl)) { // When @@ -593,22 +535,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)); @@ -629,13 +571,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(); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r847a54f246d108d48f712fef5e1b961523f2c453 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 847a54f246d108d48f712fef5e1b961523f2c453) @@ -120,12 +120,12 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); mocks.ReplayAll(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call var children = info.ChildNodeObjects(groupContext); @@ -138,7 +138,7 @@ public void ChildNodeObjects_GroupWithMixedContents_ReturnChildren() { // Setup - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); mocks.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); @@ -151,7 +151,7 @@ var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); // Call object[] children = info.ChildNodeObjects(groupContext).ToArray(); @@ -161,10 +161,10 @@ var calculationGroupContext = (StabilityPointStructuresCalculationGroupContext) children[0]; Assert.AreSame(childGroup, calculationGroupContext.WrappedData); Assert.AreSame(failureMechanism, calculationGroupContext.FailureMechanism); - Assert.AreSame(assessmentSectionStub, calculationGroupContext.AssessmentSection); + Assert.AreSame(assessmentSection, calculationGroupContext.AssessmentSection); var calculationContext = (StabilityPointStructuresCalculationContext) children[1]; Assert.AreSame(childCalculation, calculationContext.WrappedData); - Assert.AreSame(assessmentSectionStub, calculationContext.AssessmentSection); + Assert.AreSame(assessmentSection, calculationContext.AssessmentSection); } [Test] @@ -173,10 +173,10 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilderMock = mocks.StrictMock(); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -216,10 +216,10 @@ // Setup var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -274,11 +274,11 @@ var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.StabilityPointStructures.Add(new TestStabilityPointStructure()); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var treeViewControl = new TreeViewControl()) @@ -303,12 +303,9 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() { // Setup - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var group = new CalculationGroup { Children = @@ -317,62 +314,15 @@ } }; - var nodeData = new StabilityPointStructuresCalculationGroupContext(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_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() - { - // Setup - var group = new CalculationGroup - { - Children = - { - new StructuresCalculation() - } - }; - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - 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 StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -402,7 +352,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() { // Setup var group = new CalculationGroup @@ -414,18 +364,14 @@ }; var failureMechanism = new StabilityPointStructuresFailureMechanism(); - 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 StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -457,7 +403,7 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemCalculateAndValidateAllEnabled() + public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemCalculateAndValidateAllEnabled() { // Setup var group = new CalculationGroup @@ -477,18 +423,14 @@ }; var failureMechanism = new StabilityPointStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionStub = mocks.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = mocks.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -523,13 +465,13 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentGroupContext = new StabilityPointStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { var menuBuilderMock = mocks.StrictMock(); @@ -566,13 +508,13 @@ var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var groupContext = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentGroupContext = new StabilityPointStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); @@ -621,10 +563,10 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var calculationGroup = new CalculationGroup { Name = "Nieuwe map" @@ -667,16 +609,16 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var calculationItem = 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()) { @@ -686,7 +628,7 @@ mocks.ReplayAll(); group.Children.Add(calculationItem); - nodeData.Attach(observerMock); + nodeData.Attach(observer); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { @@ -710,17 +652,10 @@ public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() { // Setup - var mainWindowStub = mocks.Stub(); + var mainWindow = mocks.Stub(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(2, 2) - })); - failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation { Name = "A", @@ -745,26 +680,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.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 StabilityPointStructuresCalculationGroupContext(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) => @@ -806,12 +740,6 @@ var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - - failureMechanism.AddSection(new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - })); - failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation { Name = "A", @@ -836,13 +764,14 @@ 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 StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -851,8 +780,6 @@ mocks.ReplayAll(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; - plugin.Gui = guiMock; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(groupContext, null, treeViewControl)) @@ -879,7 +806,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); StabilityPointStructure structure1 = new TestStabilityPointStructure("Structure 1"); StabilityPointStructure structure2 = new TestStabilityPointStructure("Structure 2"); @@ -895,7 +822,7 @@ var nodeData = new StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -937,7 +864,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); StabilityPointStructure structure1 = new TestStabilityPointStructure("Structure 1"); StabilityPointStructure structure2 = new TestStabilityPointStructure("Structure 2"); @@ -953,7 +880,7 @@ var nodeData = new StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -993,7 +920,7 @@ // Given using (var treeViewControl = new TreeViewControl()) { - var assessmentSectionMock = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var existingCalculationName = "StabilityPoint structure"; StabilityPointStructure stabilityPointStructure = new TestStabilityPointStructure(existingCalculationName); @@ -1018,7 +945,7 @@ var nodeData = new StabilityPointStructuresCalculationGroupContext(failureMechanism.CalculationsGroup, failureMechanism, - assessmentSectionMock); + assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1060,23 +987,23 @@ public void OnNodeRemoved_NestedCalculationGroup_RemoveGroupAndNotifyObservers() { // Setup - var observerMock = mocks.StrictMock(); + var observer = mocks.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentNodeData = new StabilityPointStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); - observerMock.Expect(o => o.UpdateObserver()); + observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); parentGroup.Children.Add(group); - parentNodeData.Attach(observerMock); + parentNodeData.Attach(observer); // Precondition Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); @@ -1093,15 +1020,15 @@ { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); + var assessmentSection = mocks.Stub(); var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentNodeData = new StabilityPointStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); mocks.ReplayAll(); @@ -1129,26 +1056,26 @@ public void OnNodeRemoved_NestedCalculationGroupContainingCalculations_RemoveGroupAndCalculationsAndNotifyObservers() { // Setup - var observerMock = mocks.StrictMock(); - var assessmentSectionStub = mocks.Stub(); + var observer = mocks.StrictMock(); + var assessmentSection = mocks.Stub(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var group = new CalculationGroup(); var parentGroup = new CalculationGroup(); var nodeData = new StabilityPointStructuresCalculationGroupContext(group, failureMechanism, - assessmentSectionStub); + assessmentSection); var parentNodeData = new StabilityPointStructuresCalculationGroupContext(parentGroup, failureMechanism, - assessmentSectionStub); + assessmentSection); var calculation = new StructuresCalculation(); - observerMock.Expect(o => o.UpdateObserver()); + observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); group.Children.Add(calculation); parentGroup.Children.Add(group); - parentNodeData.Attach(observerMock); + parentNodeData.Attach(observer); // Precondition Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r847a54f246d108d48f712fef5e1b961523f2c453 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 847a54f246d108d48f712fef5e1b961523f2c453) @@ -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; @@ -104,11 +103,11 @@ public void ChildNodeObjects_FailureMechanismIsRelevant_ReturnChildDataNodes() { // Setup - var assessmentSectionMock = mocksRepository.Stub(); + var assessmentSection = mocksRepository.Stub(); mocksRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { @@ -127,17 +126,17 @@ Assert.AreEqual(4, inputsFolder.Contents.Count); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0]; Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); - Assert.AreSame(assessmentSectionMock, failureMechanismSectionsContext.ParentAssessmentSection); + Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection); var profilesContext = (ForeshoreProfilesContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); Assert.AreSame(failureMechanism, profilesContext.ParentFailureMechanism); - Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); + Assert.AreSame(assessmentSection, profilesContext.ParentAssessmentSection); var stabilityPointStructuresContext = (StabilityPointStructuresContext) inputsFolder.Contents[2]; Assert.AreSame(failureMechanism.StabilityPointStructures, stabilityPointStructuresContext.WrappedData); Assert.AreSame(failureMechanism, stabilityPointStructuresContext.FailureMechanism); - Assert.AreSame(assessmentSectionMock, stabilityPointStructuresContext.AssessmentSection); + Assert.AreSame(assessmentSection, stabilityPointStructuresContext.AssessmentSection); var inputComment = (Comment) inputsFolder.Contents[3]; Assert.AreSame(failureMechanism.InputComments, inputComment); @@ -170,14 +169,14 @@ public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments() { // Setup - var assessmentSectionMock = mocksRepository.Stub(); + var assessmentSection = mocksRepository.Stub(); mocksRepository.ReplayAll(); var failureMechanism = new StabilityPointStructuresFailureMechanism { IsRelevant = false }; - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) { @@ -199,8 +198,8 @@ { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var assessmentSection = mocksRepository.Stub(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var guiMock = mocksRepository.StrictMock(); var menuBuilderMock = mocksRepository.StrictMock(); @@ -243,8 +242,8 @@ { IsRelevant = false }; - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var assessmentSection = mocksRepository.Stub(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var guiMock = mocksRepository.StrictMock(); var menuBuilderMock = mocksRepository.StrictMock(); @@ -278,9 +277,9 @@ using (var plugin = new StabilityPointStructuresPlugin()) using (var treeView = new TreeViewControl()) { - var assessmentSectionMock = mocksRepository.Stub(); + var assessmentSection = mocksRepository.Stub(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); @@ -294,7 +293,7 @@ var info = GetInfo(plugin); // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) + using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSection, treeView)) { // Assert Assert.AreEqual(12, menu.Items.Count); @@ -334,12 +333,12 @@ using (var plugin = new StabilityPointStructuresPlugin()) using (var treeView = new TreeViewControl()) { - var assessmentSectionMock = mocksRepository.Stub(); + var assessmentSection = mocksRepository.Stub(); var failureMechanism = new StabilityPointStructuresFailureMechanism { IsRelevant = false }; - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); @@ -353,7 +352,7 @@ var info = GetInfo(plugin); // Call - using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) + using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSection, treeView)) { // Assert Assert.AreEqual(4, menu.Items.Count); @@ -372,14 +371,14 @@ { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); - var viewCommandsMock = mocksRepository.StrictMock(); + var assessmentSection = mocksRepository.Stub(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var viewCommands = mocksRepository.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); - viewCommandsMock.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); - guiMock.Stub(g => g.ViewCommands).Return(viewCommandsMock); + viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); + guiMock.Stub(g => g.ViewCommands).Return(viewCommands); using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl()) @@ -412,14 +411,14 @@ { IsRelevant = false }; - var assessmentSectionMock = mocksRepository.Stub(); - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); - var viewCommandsMock = mocksRepository.StrictMock(); + var assessmentSection = mocksRepository.Stub(); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); + var viewCommands = mocksRepository.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var guiMock = mocksRepository.StrictMock(); - viewCommandsMock.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); - guiMock.Stub(g => g.ViewCommands).Return(viewCommandsMock); + viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext)); + guiMock.Stub(g => g.ViewCommands).Return(viewCommands); using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl()) @@ -445,60 +444,16 @@ } [Test] - public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_NoHydraulicBoundaryDatabase_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - var assessmentSectionMock = mocksRepository.Stub(); - var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var assessmentSection = mocksRepository.Stub(); - using (var plugin = new StabilityPointStructuresPlugin()) - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); - mocksRepository.ReplayAll(); - - var info = GetInfo(plugin); - 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_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() - { - // Setup - var guiMock = mocksRepository.StrictMock(); - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - - var assessmentSectionMock = mocksRepository.Stub(); - - var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var plugin = new StabilityPointStructuresPlugin()) @@ -530,21 +485,17 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsSetHydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotValid_ContextMenuItemCalculateAndValidateAllDisabledAndTooltipSet() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); - var assessmentSectionMock = mocksRepository.Stub(); - assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var plugin = new StabilityPointStructuresPlugin()) @@ -578,16 +529,12 @@ } [Test] - public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemCalculateAndValidateAllEnabled() + public void ContextMenuStrip_HydraulicDatabaseSet_ContextMenuItemCalculateAndValidateAllEnabled() { // Setup var guiMock = mocksRepository.StrictMock(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(new StructuresCalculation()); - failureMechanism.AddSection(new FailureMechanismSection("test", new[] - { - new Point2D(0, 0) - })); string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); @@ -597,10 +544,10 @@ Version = "1.0" }; - var assessmentSectionMock = mocksRepository.Stub(); - assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var plugin = new StabilityPointStructuresPlugin()) @@ -634,18 +581,10 @@ { // Setup var guiMock = mocksRepository.StrictMock(); - var mainWindowStub = mocksRepository.Stub(); + var mainWindow = mocksRepository.Stub(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0), - new Point2D(2, 2) - }); - failureMechanism.AddSection(section); - failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation { Name = "A", @@ -671,21 +610,21 @@ string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - var hydraulicBoundaryDatabaseStub = mocksRepository.Stub(); - hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + var hydraulicBoundaryDatabase = mocksRepository.Stub(); + hydraulicBoundaryDatabase.FilePath = validFilePath; - var assessmentSectionStub = mocksRepository.Stub(); - assessmentSectionStub.Stub(a => a.Id).Return(string.Empty); - assessmentSectionStub.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 1)); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionStub); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl()) { guiMock.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder); - guiMock.Expect(g => g.MainWindow).Return(mainWindowStub); + guiMock.Expect(g => g.MainWindow).Return(mainWindow); mocksRepository.ReplayAll(); @@ -729,11 +668,6 @@ { // Setup var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var section = new FailureMechanismSection("A", new[] - { - new Point2D(0, 0) - }); - failureMechanism.AddSection(section); failureMechanism.CalculationsGroup.Children.Add(new TestStabilityPointStructuresCalculation { Name = "A", @@ -757,13 +691,13 @@ string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - var hydraulicBoundaryDatabaseStub = mocksRepository.Stub(); - hydraulicBoundaryDatabaseStub.FilePath = validFilePath; + var hydraulicBoundaryDatabase = mocksRepository.Stub(); + hydraulicBoundaryDatabase.FilePath = validFilePath; - var assessmentSectionMock = mocksRepository.Stub(); - assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabaseStub; + var assessmentSection = mocksRepository.Stub(); + assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSectionMock); + var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl())