Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs
===================================================================
diff -u -r7343a55e81349863d0e5d7bec5c7f0b3577adf65 -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision 7343a55e81349863d0e5d7bec5c7f0b3577adf65)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
@@ -85,15 +85,17 @@
/// A object.
public static TreeNodeInfo CreateCalculationContextTreeNodeInfo(
Bitmap icon,
- Func childeNodeObjects)
+ Func childeNodeObjects,
+ Func contextMenuStrip)
where TCalculationContext : ICalculationContext
{
return new TreeNodeInfo
{
Text = context => context.WrappedData.Name,
Image = context => icon,
EnsureVisibleOnCreate = (context, parent) => true,
- ChildNodeObjects = childeNodeObjects
+ ChildNodeObjects = childeNodeObjects,
+ ContextMenuStrip = contextMenuStrip
};
}
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs
===================================================================
diff -u -r7343a55e81349863d0e5d7bec5c7f0b3577adf65 -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision 7343a55e81349863d0e5d7bec5c7f0b3577adf65)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
@@ -984,14 +984,16 @@
// Setup
var icon = RingtoetsFormsResources.CalculateIcon;
Func childNodeObjects = context => new object[0];
+ Func contextMenuStrip = (context, parent, treeViewControl) => new ContextMenuStrip();
// Call
- var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(icon, childNodeObjects);
+ var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(icon, childNodeObjects, contextMenuStrip);
// Assert
Assert.AreEqual(typeof(TestCalculationContext), treeNodeInfo.TagType);
TestHelper.AssertImagesAreEqual(icon, treeNodeInfo.Image(null));
Assert.AreSame(childNodeObjects, treeNodeInfo.ChildNodeObjects);
+ Assert.AreSame(contextMenuStrip, treeNodeInfo.ContextMenuStrip);
Assert.IsNull(treeNodeInfo.ForeColor);
Assert.IsNull(treeNodeInfo.CanCheck);
Assert.IsNull(treeNodeInfo.IsChecked);
@@ -1014,7 +1016,7 @@
};
var context = new TestCalculationContext(calculation, failureMechanismMock);
- var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(null, null);
+ var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(null, null, null);
// Call
var text = treeNodeInfo.Text(context);
@@ -1028,7 +1030,7 @@
public void EnsureVisibleOnCreateOfCalculationContextTreeNodeInfo_Always_ReturnsTrue()
{
// Setup
- var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(null, null);
+ var treeNodeInfo = CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(null, null, null);
// Call
var result = treeNodeInfo.EnsureVisibleOnCreate(null, null);
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs
===================================================================
diff -u -r7343a55e81349863d0e5d7bec5c7f0b3577adf65 -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 7343a55e81349863d0e5d7bec5c7f0b3577adf65)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
@@ -77,16 +77,9 @@
yield return CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(
GrassCoverErosionInwardsFormsResources.CalculationIcon,
- CalculationContextChildNodeObjects);
+ CalculationContextChildNodeObjects,
+ null);
-// yield return new TreeNodeInfo
-// {
-// Text = context => context.WrappedData.Name,
-// Image = context => GrassCoverErosionInwardsFormsResources.CalculationIcon,
-// EnsureVisibleOnCreate = (context, parent) => true,
-// ChildNodeObjects = CalculationContextChildNodeObjects
-// };
-
yield return new TreeNodeInfo
{
Text = pipingInputContext => GrassCoverErosionInwardsFormsResources.GrassCoverErosionInwardsInputContext_NodeDisplayName,
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -r7343a55e81349863d0e5d7bec5c7f0b3577adf65 -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 7343a55e81349863d0e5d7bec5c7f0b3577adf65)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
@@ -121,7 +121,8 @@
yield return CalculationTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(
PipingFormsResources.PipingIcon,
- PipingCalculationContextChildNodeObjects);
+ PipingCalculationContextChildNodeObjects,
+ PipingCalculationContextContextMenuStrip);
yield return CalculationTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(
PipingCalculationGroupContextChildNodeObjects,
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs
===================================================================
diff -u -r7343a55e81349863d0e5d7bec5c7f0b3577adf65 -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 7343a55e81349863d0e5d7bec5c7f0b3577adf65)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
@@ -196,117 +196,117 @@
// Assert.IsTrue(canDrag);
// }
//
+ [Test]
+ public void ContextMenuStrip_PipingCalculationWithoutOutput_ContextMenuItemClearOutputDisabled()
+ {
+ // Setup
+ var gui = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var nodeData = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
+
+ // Assert
+ mocks.VerifyAll(); // Expect no calls on arguments
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, RingtoetsCommonFormsResources.Validate, RingtoetsCommonFormsResources.Validate_ToolTip, RingtoetsCommonFormsResources.ValidateIcon);
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 1, RingtoetsCommonFormsResources.Calculate, RingtoetsCommonFormsResources.Calculate_ToolTip, RingtoetsCommonFormsResources.CalculateIcon);
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 2, PipingFormsResources.Clear_output, PipingFormsResources.ClearOutput_No_output_to_clear, RingtoetsCommonFormsResources.ClearIcon, false);
+ }
+
+ [Test]
+ public void ContextMenuStrip_PipingCalculationWithOutput_ContextMenuItemClearOutputEnabled()
+ {
+ var gui = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput())
+ {
+ Output = new TestPipingOutput()
+ };
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var nodeData = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
+
+ // Assert
+ mocks.VerifyAll(); // Expect no calls on arguments
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, RingtoetsCommonFormsResources.Validate, RingtoetsCommonFormsResources.Validate_ToolTip, RingtoetsCommonFormsResources.ValidateIcon);
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 1, RingtoetsCommonFormsResources.Calculate, RingtoetsCommonFormsResources.Calculate_ToolTip, RingtoetsCommonFormsResources.CalculateIcon);
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, 2, PipingFormsResources.Clear_output, PipingFormsResources.Clear_output_ToolTip, RingtoetsCommonFormsResources.ClearIcon);
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.Stub();
+ var treeViewControlMock = mocks.StrictMock();
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var nodeData = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput()),
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(menuBuilderMock);
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(nodeData, null, treeViewControlMock);
+
+ // Assert
+ mocks.VerifyAll(); // Expect no calls on arguments
+ }
+
// [Test]
-// public void ContextMenuStrip_PipingCalculationWithoutOutput_ContextMenuItemClearOutputDisabled()
-// {
-// // Setup
-// var gui = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var nodeData = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// // Call
-// var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
-//
-// // Assert
-// mocks.VerifyAll(); // Expect no calls on arguments
-//
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, RingtoetsCommonFormsResources.Validate, RingtoetsCommonFormsResources.Validate_ToolTip, RingtoetsCommonFormsResources.ValidateIcon);
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 1, RingtoetsCommonFormsResources.Calculate, RingtoetsCommonFormsResources.Calculate_ToolTip, RingtoetsCommonFormsResources.CalculateIcon);
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 2, PipingFormsResources.Clear_output, PipingFormsResources.ClearOutput_No_output_to_clear, RingtoetsCommonFormsResources.ClearIcon, false);
-// }
-//
-// [Test]
-// public void ContextMenuStrip_PipingCalculationWithOutput_ContextMenuItemClearOutputEnabled()
-// {
-// var gui = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput())
-// {
-// Output = new TestPipingOutput()
-// };
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var nodeData = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// // Call
-// var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
-//
-// // Assert
-// mocks.VerifyAll(); // Expect no calls on arguments
-//
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, RingtoetsCommonFormsResources.Validate, RingtoetsCommonFormsResources.Validate_ToolTip, RingtoetsCommonFormsResources.ValidateIcon);
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 1, RingtoetsCommonFormsResources.Calculate, RingtoetsCommonFormsResources.Calculate_ToolTip, RingtoetsCommonFormsResources.CalculateIcon);
-// TestHelper.AssertContextMenuStripContainsItem(contextMenu, 2, PipingFormsResources.Clear_output, PipingFormsResources.Clear_output_ToolTip, RingtoetsCommonFormsResources.ClearIcon);
-// }
-//
-// [Test]
-// public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
-// {
-// // Setup
-// var gui = mocks.StrictMock();
-// var menuBuilderMock = mocks.Stub();
-// var treeViewControlMock = mocks.StrictMock();
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var nodeData = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput()),
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
-// menuBuilderMock.Expect(mb => mb.Build()).Return(null);
-//
-// gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(menuBuilderMock);
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// // Call
-// info.ContextMenuStrip(nodeData, null, treeViewControlMock);
-//
-// // Assert
-// mocks.VerifyAll(); // Expect no calls on arguments
-// }
-//
-// [Test]
// [TestCase(true)]
// [TestCase(false)]
// public void CanRemove_ParentIsCalculationGroupWithCalculation_ReturnTrue(bool groupNameEditable)
@@ -495,227 +495,227 @@
// mocks.VerifyAll();
// }
//
-// [Test]
-// public void GivenInvalidPipingCalculation_WhenCalculatingFromContextMenu_ThenPipingCalculationNotifiesObserversAndLogMessageAdded()
-// {
-// // Given
-// var gui = mocks.DynamicMock();
-// var mainWindow = mocks.DynamicMock();
-// var observer = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// observer.Expect(o => o.UpdateObserver());
-//
-// gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-// gui.Expect(g => g.MainWindow).Return(mainWindow);
-//
-// var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
-// var calculateContextMenuItemIndex = 1;
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// calculation.Attach(observer);
-//
-// var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
-//
-// DialogBoxHandler = (name, wnd) =>
-// {
-// // Don't care about dialogs in this test.
-// };
-//
-// // When
-// Action action = () => { contextMenuAdapter.Items[calculateContextMenuItemIndex].PerformClick(); };
-//
-// // Then
-// TestHelper.AssertLogMessages(action, messages =>
-// {
-// var msgs = messages.GetEnumerator();
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Validatie van 'Nieuwe berekening' gestart om: ", msgs.Current);
-// for (int i = 0; i < expectedValidationMessageCount; i++)
-// {
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Validatie mislukt: ", msgs.Current);
-// }
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Validatie van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
-// });
-// Assert.IsNull(calculation.Output);
-//
-// mocks.VerifyAll();
-// }
-//
-// [Test]
-// public void GivenInvalidPipingCalculation_WhenValidatingFromContextMenu_ThenLogMessageAddedAndNoNotifyObserver()
-// {
-// // Given
-// var gui = mocks.DynamicMock();
-// var observer = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-//
-// var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
-// var expectedStatusMessageCount = 2;
-// var expectedLogMessageCount = expectedValidationMessageCount + expectedStatusMessageCount;
-//
-// var validateContextMenuItemIndex = 0;
-// observer.Expect(o => o.UpdateObserver()).Repeat.Never();
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// calculation.Attach(observer);
-//
-// var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
-//
-// // When
-// Action action = () => contextMenuAdapter.Items[validateContextMenuItemIndex].PerformClick();
-//
-// // Then
-// TestHelper.AssertLogMessagesCount(action, expectedLogMessageCount);
-//
-// mocks.VerifyAll();
-// }
-//
-// [Test]
-// public void GivenValidPipingCalculation_WhenCalculatingFromContextMenu_ThenPipingCalculationNotifiesObservers()
-// {
-// // Given
-// var gui = mocks.DynamicMock();
-// var mainWindow = mocks.DynamicMock();
-// var observer = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculateContextMenuItemIndex = 1;
-// var calculation = PipingCalculationFactory.CreateCalculationWithValidInput();
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// gui.Expect(g => g.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-// gui.Expect(g => g.MainWindow).Return(mainWindow);
-//
-// observer.Expect(o => o.UpdateObserver());
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// calculation.Attach(observer);
-//
-// var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
-//
-// DialogBoxHandler = (name, wnd) =>
-// {
-// // Don't care about dialogs in this test.
-// };
-//
-// // When
-// Action action = () => { contextMenuAdapter.Items[calculateContextMenuItemIndex].PerformClick(); };
-//
-// // Then
-// TestHelper.AssertLogMessages(action, messages =>
-// {
-// var msgs = messages.GetEnumerator();
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Validatie van 'Nieuwe berekening' gestart om: ", msgs.Current);
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Validatie van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
-//
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Berekening van 'Nieuwe berekening' gestart om: ", msgs.Current);
-// Assert.IsTrue(msgs.MoveNext());
-// StringAssert.StartsWith("Berekening van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
-// });
-// Assert.IsNotNull(calculation.Output);
-//
-// mocks.VerifyAll();
-// }
-//
-// [Test]
-// [TestCase(true)]
-// [TestCase(false)]
-// public void GivenPipingCalculationWithOutput_WhenClearingOutputFromContextMenu_ThenPipingCalculationOutputClearedAndNotified(bool confirm)
-// {
-// // Given
-// var gui = mocks.DynamicMock();
-// var observer = mocks.StrictMock();
-// var treeViewControlMock = mocks.StrictMock();
-// var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
-// var pipingFailureMechanismMock = mocks.StrictMock();
-// var assessmentSectionMock = mocks.StrictMock();
-// var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
-// Enumerable.Empty(),
-// Enumerable.Empty(),
-// pipingFailureMechanismMock,
-// assessmentSectionMock);
-//
-// gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-//
-// int clearOutputItemPosition = 2;
-// if (confirm)
-// {
-// observer.Expect(o => o.UpdateObserver());
-// }
-//
-// mocks.ReplayAll();
-//
-// plugin.Gui = gui;
-//
-// calculation.Output = new TestPipingOutput();
-// calculation.Attach(observer);
-//
-// var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
-//
-// string messageBoxText = null, messageBoxTitle = null;
-// DialogBoxHandler = (name, wnd) =>
-// {
-// var messageBox = new MessageBoxTester(wnd);
-// messageBoxText = messageBox.Text;
-// messageBoxTitle = messageBox.Title;
-// if (confirm)
-// {
-// messageBox.ClickOk();
-// }
-// else
-// {
-// messageBox.ClickCancel();
-// }
-// };
-//
-// // When
-// contextMenuAdapter.Items[clearOutputItemPosition].PerformClick();
-//
-// // Then
-// Assert.AreNotEqual(confirm, calculation.HasOutput);
-// Assert.AreEqual("Bevestigen", messageBoxTitle);
-// Assert.AreEqual("Weet u zeker dat u de uitvoer van deze berekening wilt wissen?", messageBoxText);
-// mocks.VerifyAll();
-// }
+ [Test]
+ public void GivenInvalidPipingCalculation_WhenCalculatingFromContextMenu_ThenPipingCalculationNotifiesObserversAndLogMessageAdded()
+ {
+ // Given
+ var gui = mocks.DynamicMock();
+ var mainWindow = mocks.DynamicMock();
+ var observer = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+ observer.Expect(o => o.UpdateObserver());
+
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(g => g.MainWindow).Return(mainWindow);
+
+ var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
+ var calculateContextMenuItemIndex = 1;
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ calculation.Attach(observer);
+
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Don't care about dialogs in this test.
+ };
+
+ // When
+ Action action = () => { contextMenuAdapter.Items[calculateContextMenuItemIndex].PerformClick(); };
+
+ // Then
+ TestHelper.AssertLogMessages(action, messages =>
+ {
+ var msgs = messages.GetEnumerator();
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Validatie van 'Nieuwe berekening' gestart om: ", msgs.Current);
+ for (int i = 0; i < expectedValidationMessageCount; i++)
+ {
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Validatie mislukt: ", msgs.Current);
+ }
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Validatie van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
+ });
+ Assert.IsNull(calculation.Output);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GivenInvalidPipingCalculation_WhenValidatingFromContextMenu_ThenLogMessageAddedAndNoNotifyObserver()
+ {
+ // Given
+ var gui = mocks.DynamicMock();
+ var observer = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+
+ var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
+ var expectedStatusMessageCount = 2;
+ var expectedLogMessageCount = expectedValidationMessageCount + expectedStatusMessageCount;
+
+ var validateContextMenuItemIndex = 0;
+ observer.Expect(o => o.UpdateObserver()).Repeat.Never();
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ calculation.Attach(observer);
+
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
+
+ // When
+ Action action = () => contextMenuAdapter.Items[validateContextMenuItemIndex].PerformClick();
+
+ // Then
+ TestHelper.AssertLogMessagesCount(action, expectedLogMessageCount);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GivenValidPipingCalculation_WhenCalculatingFromContextMenu_ThenPipingCalculationNotifiesObservers()
+ {
+ // Given
+ var gui = mocks.DynamicMock();
+ var mainWindow = mocks.DynamicMock();
+ var observer = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculateContextMenuItemIndex = 1;
+ var calculation = PipingCalculationFactory.CreateCalculationWithValidInput();
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ gui.Expect(g => g.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(g => g.MainWindow).Return(mainWindow);
+
+ observer.Expect(o => o.UpdateObserver());
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ calculation.Attach(observer);
+
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Don't care about dialogs in this test.
+ };
+
+ // When
+ Action action = () => { contextMenuAdapter.Items[calculateContextMenuItemIndex].PerformClick(); };
+
+ // Then
+ TestHelper.AssertLogMessages(action, messages =>
+ {
+ var msgs = messages.GetEnumerator();
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Validatie van 'Nieuwe berekening' gestart om: ", msgs.Current);
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Validatie van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
+
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Berekening van 'Nieuwe berekening' gestart om: ", msgs.Current);
+ Assert.IsTrue(msgs.MoveNext());
+ StringAssert.StartsWith("Berekening van 'Nieuwe berekening' beëindigd om: ", msgs.Current);
+ });
+ Assert.IsNotNull(calculation.Output);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void GivenPipingCalculationWithOutput_WhenClearingOutputFromContextMenu_ThenPipingCalculationOutputClearedAndNotified(bool confirm)
+ {
+ // Given
+ var gui = mocks.DynamicMock();
+ var observer = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
+ var pipingFailureMechanismMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+ var pipingCalculationContext = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanismMock,
+ assessmentSectionMock);
+
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+
+ int clearOutputItemPosition = 2;
+ if (confirm)
+ {
+ observer.Expect(o => o.UpdateObserver());
+ }
+
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ calculation.Output = new TestPipingOutput();
+ calculation.Attach(observer);
+
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
+
+ string messageBoxText = null, messageBoxTitle = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var messageBox = new MessageBoxTester(wnd);
+ messageBoxText = messageBox.Text;
+ messageBoxTitle = messageBox.Title;
+ if (confirm)
+ {
+ messageBox.ClickOk();
+ }
+ else
+ {
+ messageBox.ClickCancel();
+ }
+ };
+
+ // When
+ contextMenuAdapter.Items[clearOutputItemPosition].PerformClick();
+
+ // Then
+ Assert.AreNotEqual(confirm, calculation.HasOutput);
+ Assert.AreEqual("Bevestigen", messageBoxTitle);
+ Assert.AreEqual("Weet u zeker dat u de uitvoer van deze berekening wilt wissen?", messageBoxText);
+ mocks.VerifyAll();
+ }
+
///
/// Creates a new instance of with sections and a surface line.
///