Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r184de624feae0c0a051e34298d66e304d073daf5 -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 184de624feae0c0a051e34298d66e304d073daf5)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -256,6 +256,15 @@
}
///
+ /// Looks up a localized string similar to Valideer alle berekeningen binnen deze berekeningsmap..
+ ///
+ public static string CalculationGroup_Validate_all_ToolTip {
+ get {
+ return ResourceManager.GetString("CalculationGroup_Validate_all_ToolTip", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Resultaat.
///
public static string CalculationOutput_DisplayName {
@@ -496,6 +505,15 @@
}
///
+ /// Looks up a localized string similar to Valideer alle berekeningen binnen dit toetsspoor..
+ ///
+ public static string FailureMechanism_Validate_all_ToolTip {
+ get {
+ return ResourceManager.GetString("FailureMechanism_Validate_all_ToolTip", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to I&s relevant.
///
public static string FailureMechanismContextMenuStrip_Is_relevant {
@@ -951,20 +969,20 @@
}
///
- /// Looks up a localized string similar to Valideer alle berekeningen binnen dit toetsspoor..
+ /// Looks up a localized string similar to Valideer de invoer voor deze berekening..
///
- public static string Validate_all_ToolTip {
+ public static string Validate_ToolTip {
get {
- return ResourceManager.GetString("Validate_all_ToolTip", resourceCulture);
+ return ResourceManager.GetString("Validate_ToolTip", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Valideer de invoer voor deze berekening..
+ /// Looks up a localized string similar to Er zijn geen berekeningen om te valideren..
///
- public static string Validate_ToolTip {
+ public static string ValidateAll_No_calculations_to_validate {
get {
- return ResourceManager.GetString("Validate_ToolTip", resourceCulture);
+ return ResourceManager.GetString("ValidateAll_No_calculations_to_validate", resourceCulture);
}
}
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx
===================================================================
diff -u -r184de624feae0c0a051e34298d66e304d073daf5 -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 184de624feae0c0a051e34298d66e304d073daf5)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -196,7 +196,7 @@
Alles &valideren
-
+
Valideer alle berekeningen binnen dit toetsspoor.
@@ -418,4 +418,10 @@
..\resources\wand-hat.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ Er zijn geen berekeningen om te valideren.
+
+
+ Valideer alle berekeningen binnen deze berekeningsmap.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs
===================================================================
diff -u -ra3357275af675af3714fc89b99c554c288759ae2 -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision a3357275af675af3714fc89b99c554c288759ae2)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -89,44 +89,88 @@
/// The calculation group to perform all calculations for.
/// The calculation group context belonging to the calculation group.
/// The action that performs all calculations.
- /// The func for performing additional validation checks.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The itself.
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public RingtoetsContextMenuBuilder AddPerformAllCalculationsInGroupItem(
CalculationGroup calculationGroup,
TCalculationContext calculationGroupContext,
Action calculateAllAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction = null)
where TCalculationContext : ICalculationContext
{
- contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, calculateAllAction, additionalValidationFunc));
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, calculateAllAction, enableMenuItemFunction));
return this;
}
///
+ /// Adds an item to the , which validates all calculations in a calculation group.
+ ///
+ /// The type of the calculation group context.
+ /// The calculation group to validate all calculations for.
+ /// The calculation group context belonging to the calculation group.
+ /// The action that validates all calculations.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The itself.
+ public RingtoetsContextMenuBuilder AddValidateAllCalculationsInGroupItem(
+ CalculationGroup calculationGroup,
+ TCalculationContext calculationGroupContext,
+ Action validateAllAction,
+ Func enableMenuItemFunction = null)
+ where TCalculationContext : ICalculationContext
+ {
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, validateAllAction, enableMenuItemFunction));
+ return this;
+ }
+
+ ///
/// Adds an item to the , which performs a calculation.
///
/// The type of the calculation.
/// The type of the calculation context.
/// The calculation to perform.
/// The calculation context belonging to the calculation.
/// The action that performs the calculation.
- /// The func for performing additional validation checks.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The itself.
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public RingtoetsContextMenuBuilder AddPerformCalculationItem(
TCalculation calculation,
TCalculationContext calculationContext,
Action calculateAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction = null)
where TCalculationContext : ICalculationContext
where TCalculation : ICalculation
{
- contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformCalculationItem(calculation, calculationContext, calculateAction, additionalValidationFunc));
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformCalculationItem(calculation, calculationContext, calculateAction, enableMenuItemFunction));
return this;
}
///
+ /// Adds an item to the , which validates a calculation.
+ ///
+ /// The type of the calculation.
+ /// The calculation to validate.
+ /// The action that validates the calculation.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The itself.
+ public RingtoetsContextMenuBuilder AddValidateCalculationItem(
+ TCalculation calculation,
+ Action validateAction,
+ Func enableMenuItemFunction = null)
+ where TCalculation : ICalculation
+ {
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateCalculationItem(calculation, validateAction, enableMenuItemFunction));
+ return this;
+ }
+
+ ///
/// Adds an item to the , which clears the output of a calculation.
///
/// The calculation to clear the output for.
@@ -154,20 +198,43 @@
/// The type of the failure mechanism context.
/// The failure mechanism context belonging to the failure mechanism.
/// The action that performs all calculations.
- /// The func for performing additional validation checks.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The itself.
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public RingtoetsContextMenuBuilder AddPerformAllCalculationsInFailureMechanismItem(
TFailureMechanismContext failureMechanismContext,
Action calculateAllAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction = null)
where TFailureMechanismContext : IFailureMechanismContext
{
- contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, calculateAllAction, additionalValidationFunc));
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreatePerformAllCalculationsInFailureMechanismItem(failureMechanismContext, calculateAllAction, enableMenuItemFunction));
return this;
}
///
+ /// Adds an item to the , which validates all calculations in a failure mechanism.
+ ///
+ /// The type of the failure mechanism context.
+ /// The failure mechanism context belonging to the failure mechanism.
+ /// The action that validates all calculations.
+ /// An optional function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The itself.
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
+ public RingtoetsContextMenuBuilder AddValidateAllCalculationsInFailureMechanismItem(
+ TFailureMechanism failureMechanism,
+ Action validateAllAction,
+ Func enableMenuItemFunction = null)
+ where TFailureMechanism : IFailureMechanism
+ {
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, validateAllAction, enableMenuItemFunction));
+ return this;
+ }
+
+ ///
/// Adds an item to the , which sets if the failure mechanism is relevant.
///
/// The type of the failure mechanism context.
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs
===================================================================
diff -u -rc796a449aa7622c4c2386279a7f9fb410f610444 -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision c796a449aa7622c4c2386279a7f9fb410f610444)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -100,72 +100,131 @@
/// The calculation group to perform all calculations for.
/// The calculation group context belonging to the calculation group.
/// The action that performs all calculations.
- /// The func for performing additional validation checks.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The created .
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformAllCalculationsInGroupItem(
CalculationGroup calculationGroup,
TCalculationContext calculationGroupContext,
Action calculateAllAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction)
where TCalculationContext : ICalculationContext
{
- var validationText = additionalValidationFunc(calculationGroupContext);
-
- var performAllItem = new StrictContextMenuItem(
+ var menuItem = new StrictContextMenuItem(
Resources.Calculate_all,
Resources.CalculationGroup_CalculateAll_ToolTip,
Resources.CalculateAllIcon,
(o, args) => calculateAllAction(calculationGroup, calculationGroupContext));
if (!calculationGroupContext.WrappedData.GetCalculations().Any())
{
- performAllItem.Enabled = false;
- performAllItem.ToolTipText = Resources.CalculationGroup_CalculateAll_No_calculations_to_run;
+ menuItem.Enabled = false;
+ menuItem.ToolTipText = Resources.CalculationGroup_CalculateAll_No_calculations_to_run;
}
- else if (!string.IsNullOrEmpty(validationText))
+ else
{
- performAllItem.Enabled = false;
- performAllItem.ToolTipText = validationText;
+ SetStateWithEnableFunction(calculationGroupContext, enableMenuItemFunction, menuItem);
}
- return performAllItem;
+ return menuItem;
}
///
+ /// Creates a which is bound to the action of validating the input of each calculation
+ /// in a calculation group.
+ ///
+ /// The type of the calculation group context.
+ /// The calculation group to validate all calculations for.
+ /// The calculation group context belonging to the calculation group.
+ /// The action that validates all calculations.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The created .
+ public static StrictContextMenuItem CreateValidateAllCalculationsInGroupItem(
+ CalculationGroup calculationGroup,
+ TCalculationContext calculationGroupContext,
+ Action validateAllAction,
+ Func enableMenuItemFunction)
+ where TCalculationContext : ICalculationContext
+ {
+ var menuItem = new StrictContextMenuItem(
+ Resources.Validate_all,
+ Resources.CalculationGroup_Validate_all_ToolTip,
+ Resources.ValidateAllIcon,
+ (o, args) => validateAllAction(calculationGroup, calculationGroupContext));
+
+ if (!calculationGroupContext.WrappedData.GetCalculations().Any())
+ {
+ menuItem.Enabled = false;
+ menuItem.ToolTipText = Resources.ValidateAll_No_calculations_to_validate;
+ }
+ else
+ {
+ SetStateWithEnableFunction(calculationGroupContext, enableMenuItemFunction, menuItem);
+ }
+
+ return menuItem;
+ }
+
+ ///
/// Creates a which is bound to the action of performing a calculation.
///
/// The type of the calculation.
/// The type of the calculation context.
/// The calculation to perform.
/// The calculation context belonging to the calculation.
/// The action that performs the calculation.
- /// The func for performing additional validation checks.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The created .
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformCalculationItem(
TCalculation calculation,
TCalculationContext calculationContext,
Action calculateAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction)
where TCalculationContext : ICalculationContext
where TCalculation : ICalculation
{
- var validationText = additionalValidationFunc(calculationContext);
- var nodeEnabled = string.IsNullOrEmpty(validationText);
-
- return new StrictContextMenuItem(
+ var menuItem = new StrictContextMenuItem(
Resources.Calculate,
Resources.Calculate_ToolTip,
Resources.CalculateIcon,
- (o, args) => calculateAction(calculation, calculationContext))
- {
- Enabled = nodeEnabled,
- ToolTipText = nodeEnabled ? Resources.Calculate_ToolTip : validationText
- };
+ (o, args) => calculateAction(calculation, calculationContext));
+
+ SetStateWithEnableFunction(calculationContext, enableMenuItemFunction, menuItem);
+ return menuItem;
}
///
+ /// Creates a which is bound to the action of validating the input of a calculation.
+ ///
+ /// The type of the calculation.
+ /// The calculation to validate.
+ /// The action that performs the validation.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The created .
+ public static StrictContextMenuItem CreateValidateCalculationItem(
+ TCalculation calculation,
+ Action validateAction,
+ Func enableMenuItemFunction)
+ where TCalculation : ICalculation
+ {
+ var menuItem = new StrictContextMenuItem(
+ Resources.Validate,
+ Resources.Validate_ToolTip,
+ Resources.ValidateIcon,
+ (o, args) => validateAction(calculation));
+
+ SetStateWithEnableFunction(calculation, enableMenuItemFunction, menuItem);
+ return menuItem;
+ }
+
+ ///
/// Creates a which is bound to the action of clearing the output of a calculation.
///
/// The calculation to clear the output for.
@@ -214,38 +273,72 @@
/// The type of the failure mechanism context.
/// The failure mechanism context belonging to the failure mechanism.
/// The action that performs all calculations.
- /// The func for performing additional validation checks.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
/// The created .
- /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
+ /// When returns a string, the item will be disabled and the string will be shown in the tooltip.
public static StrictContextMenuItem CreatePerformAllCalculationsInFailureMechanismItem(
TFailureMechanismContext failureMechanismContext,
Action calculateAllAction,
- Func additionalValidationFunc)
+ Func enableMenuItemFunction)
where TFailureMechanismContext : IFailureMechanismContext
{
- var validationText = additionalValidationFunc(failureMechanismContext);
-
- var performAllItem = new StrictContextMenuItem(
+ var menuItem = new StrictContextMenuItem(
Resources.Calculate_all,
Resources.Calculate_all_ToolTip,
Resources.CalculateAllIcon,
(o, args) => calculateAllAction(failureMechanismContext));
if (!failureMechanismContext.WrappedData.Calculations.Any())
{
- performAllItem.Enabled = false;
- performAllItem.ToolTipText = Resources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run;
+ menuItem.Enabled = false;
+ menuItem.ToolTipText = Resources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run;
}
- else if (!string.IsNullOrEmpty(validationText))
+ else
{
- performAllItem.Enabled = false;
- performAllItem.ToolTipText = validationText;
+ SetStateWithEnableFunction(failureMechanismContext, enableMenuItemFunction, menuItem);
}
- return performAllItem;
+ return menuItem;
}
///
+ /// Creates a which is bound to the action of performing all calculations in a failure mechanism.
+ ///
+ /// The type of the failure mechanism.
+ /// The failure mechanism to validate the calculations of.
+ /// The action that validates all calculations.
+ /// The function which determines whether the item should be enabled. If the
+ /// item should not be enabled, then the reason for that should be returned by the function and will be shown as a tooltip.
+ /// If the item should be enabled then the function should return a null or empty string.
+ /// The created .
+ public static StrictContextMenuItem CreateValidateAllCalculationsInFailureMechanismItem(
+ TFailureMechanism failureMechanism,
+ Action validateAllAction,
+ Func enableMenuItemFunction)
+ where TFailureMechanism : IFailureMechanism
+ {
+ var menuItem = new StrictContextMenuItem(
+ Resources.Validate_all,
+ Resources.FailureMechanism_Validate_all_ToolTip,
+ Resources.ValidateAllIcon,
+ (o, args) => validateAllAction(failureMechanism));
+
+ if (!failureMechanism.Calculations.Any())
+ {
+ menuItem.Enabled = false;
+ menuItem.ToolTipText = Resources.ValidateAll_No_calculations_to_validate;
+ }
+ else
+ {
+ SetStateWithEnableFunction(failureMechanism, enableMenuItemFunction, menuItem);
+ }
+
+ return menuItem;
+ }
+
+ ///
/// Creates a which is bound to the action of changing the relevance of a failure mechanism.
///
/// The type of the failure mechanism context.
@@ -275,6 +368,16 @@
});
}
+ private static void SetStateWithEnableFunction(T context, Func enableFunction, StrictContextMenuItem menuItem)
+ {
+ var validationText = enableFunction != null ? enableFunction(context) : null;
+ if (!string.IsNullOrEmpty(validationText))
+ {
+ menuItem.Enabled = false;
+ menuItem.ToolTipText = validationText;
+ }
+ }
+
private static void ClearAllCalculationOutputInFailureMechanism(IFailureMechanism failureMechanism)
{
if (MessageBox.Show(Resources.FailureMechanism_ContextMenuStrip_Are_you_sure_clear_all_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK)
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs
===================================================================
diff -u -rd65d6b037600ccd69f386d9164172dd2c133356e -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision d65d6b037600ccd69f386d9164172dd2c133356e)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -605,7 +605,7 @@
}
[Test]
- public void AddPerformCalculationItem_AdditionalValidationConatainsMessage_ItemAddedToContextMenuDisabledWithMessageInTooltip()
+ public void AddPerformCalculationItem_AdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithMessageInTooltip()
{
// Setup
var mocks = new MockRepository();
@@ -642,6 +642,75 @@
#endregion
+ #region AddValidateCalculationItem
+
+ [Test]
+ public void AddValidateCalculationItem_AdditionalValidationNull_ItemAddedToContextMenuEnabled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculation, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateCalculationItem(calculation, null, c => null).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate,
+ RingtoetsFormsResources.Validate_ToolTip,
+ RingtoetsFormsResources.ValidateIcon);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateCalculationItem_AdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithMessageInTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculation, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ var errorMessage = "No valid data";
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateCalculationItem(calculation, null, c => errorMessage).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate,
+ errorMessage,
+ RingtoetsFormsResources.ValidateIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ #endregion
+
#region AddPerformAllCalculationsInGroupItem
[Test]
@@ -803,6 +872,167 @@
#endregion
+ #region AddValidateAllCalculationsInGroupItem
+
+ [Test]
+ public void AddValidateAllCalculationsInGroupItem_GeneralValidationTrueAdditionalValidationNull_ItemAddedToContextMenuEnabled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ };
+
+ var failureMechanism = new TestFailureMechanism(new[] { calculation });
+
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculationGroup, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => null).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.CalculationGroup_Validate_all_ToolTip,
+ RingtoetsFormsResources.ValidateAllIcon);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInGroupItem_GeneralValidationFalseAdditionalValidationNull_ItemAddedToContextMenuDisabledWithGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+ var calculationGroup = new CalculationGroup();
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculationGroup, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => null).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.ValidateAll_No_calculations_to_validate,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInGroupItem_GeneralValidationTrueAdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ };
+
+ var failureMechanism = new TestFailureMechanism(new[] { calculation });
+
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculationGroup, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ var errorMessage = "Additional validation failed.";
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => errorMessage).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ errorMessage,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInGroupItem_GeneralValidationFalseAdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+ var calculationGroup = new CalculationGroup();
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, calculationGroup, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ var errorMessage = "Additional validation failed.";
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => errorMessage).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.ValidateAll_No_calculations_to_validate,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ #endregion
+
#region AddPerformAllCalculationsInFailureMechanismItem
[Test]
@@ -946,6 +1176,149 @@
#endregion
+ #region AddValidateAllCalculationsInFailureMechanismItem
+
+ [Test]
+ public void AddValidateAllCalculationsInFailureMechanismItem_GeneralValidationTrueAdditionalValidationNull_ItemAddedToContextMenuEnabled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+
+ var failureMechanism = new TestFailureMechanism(new[] { new TestCalculation() });
+ var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock);
+
+ mocks.ReplayAll();
+
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => null).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.FailureMechanism_Validate_all_ToolTip,
+ RingtoetsFormsResources.ValidateAllIcon);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInFailureMechanismItem_GeneralValidationFalseAdditionalValidationNull_ItemAddedToContextMenuDisabledWithGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+ var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock);
+
+ mocks.ReplayAll();
+
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => null).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.ValidateAll_No_calculations_to_validate,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInFailureMechanismItem_GeneralValidationTrueAdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+
+ var failureMechanism = new TestFailureMechanism(new[] { new TestCalculation() });
+ var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock);
+
+ mocks.ReplayAll();
+
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ var errorMessage = "Additional validation failed.";
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => errorMessage).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ errorMessage,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddValidateAllCalculationsInFailureMechanismItem_GeneralValidationFalseAdditionalValidationContainsMessage_ItemAddedToContextMenuDisabledWithGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var exportImportHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+ var treeViewControlMock = mocks.StrictMock();
+ var assessmentSectionMock = mocks.StrictMock();
+
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+ var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock);
+
+ mocks.ReplayAll();
+
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControlMock);
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ var errorMessage = "Additional validation failed.";
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => errorMessage).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ RingtoetsFormsResources.Validate_all,
+ RingtoetsFormsResources.ValidateAll_No_calculations_to_validate,
+ RingtoetsFormsResources.ValidateAllIcon,
+ false);
+
+ mocks.VerifyAll();
+ }
+
+ #endregion
+
# region Nested types
private class TestFailureMechanismContext : FailureMechanismContext
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs
===================================================================
diff -u -rd65d6b037600ccd69f386d9164172dd2c133356e -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision d65d6b037600ccd69f386d9164172dd2c133356e)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -671,6 +671,78 @@
#endregion
+ #region CreateValidateCalculationItem
+
+ [Test]
+ public void CreateValidateCalculationItem_AdditionalValidationNull_CreatesEnabledItem()
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateCalculationItem(calculation, null, c => null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.Validate_ToolTip, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateIcon, toolStripItem.Image);
+ Assert.IsTrue(toolStripItem.Enabled);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateValidateCalculationItem_AdditionalValidationContainsMessage_CreatesDisabledItemAndSetMessageInTooltip()
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+
+ var errorMessage = "Additional check failed.";
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateCalculationItem(calculation, null, c => errorMessage);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate, toolStripItem.Text);
+ Assert.AreEqual(errorMessage, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateValidateCalculationItem_PerformClickOnCreatedItem_PerformCalculationMethod()
+ {
+ // Setup
+ var mocks = new MockRepository();
+
+ mocks.ReplayAll();
+
+ var calculation = new TestCalculation();
+
+ var counter = 0;
+ var toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateCalculationItem(calculation, calc => counter++, c => null);
+
+ // Call
+ toolStripItem.PerformClick();
+
+ // Assert
+ Assert.AreEqual(1, counter);
+
+ mocks.VerifyAll();
+ }
+
+ #endregion
+
#region CreatePerformAllCalculationsInGroupItem
[Test]
@@ -814,6 +886,149 @@
#endregion
+ #region CreateValidateAllCalculationsInGroupItem
+
+ [Test]
+ public void CreateValidateAllCalculationsInGroupItem_GeneralValidationTrueAdditionalValidationNull_CreatesEnabledItem()
+ {
+ // Setup
+ var calculation = new TestCalculation();
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ };
+
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculation
+ });
+
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.CalculationGroup_Validate_all_ToolTip, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.CalculateAllIcon, toolStripItem.Image);
+ Assert.IsTrue(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInGroupItem_GeneralValidationFalseAdditionalValidationNull_CreatesDisabledItemAndSetGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+
+ var nestedGroup = new CalculationGroup();
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ nestedGroup
+ }
+ };
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.ValidateAll_No_calculations_to_validate, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInGroupItem_GeneralValidationTrueAdditionalValidationContainsMessage_CreatesDisabledItemAndSetMessageInTooltip()
+ {
+ // Setup
+ var calculation = new TestCalculation();
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ };
+
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculation
+ });
+
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+
+ var errorMessage = "Additional check failed.";
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => errorMessage);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(errorMessage, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInGroupItem_GeneralValidationFalseAdditionalValidationContainsMessage_CreatesDisabledItemAndSetGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+
+ var calculationGroup = new CalculationGroup();
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+
+ var errorMessage = "Additional check failed.";
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, null, context => errorMessage);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.ValidateAll_No_calculations_to_validate, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInGroupItem_PerformClickOnCreatedItem_PerformAllCalculationMethodPerformed()
+ {
+ // Setup
+ var calculation = new TestCalculation();
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculation
+ });
+
+ var counter = 0;
+ var calculationGroup = new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ };
+
+ var calculationGroupContext = new TestCalculationGroupContext(calculationGroup, failureMechanism);
+
+ var toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInGroupItem(calculationGroup, calculationGroupContext, (group, context) => counter++, context => null);
+
+ // Call
+ toolStripItem.PerformClick();
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ }
+
+ #endregion
+
#region CreatePerformAllCalculationInFailureMechanismItem
[Test]
@@ -945,6 +1160,110 @@
#endregion
+ #region CreateValidateAllCalculationsInFailureMechanismItem
+
+ [Test]
+ public void CreateValidateAllCalculationsInFailureMechanismItem_GeneralValidationTrueAdditionalValidationNull_CreatesEnabledItem()
+ {
+ // Setup
+ var calculation = new TestCalculation();
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculation
+ });
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.FailureMechanism_Validate_all_ToolTip, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsTrue(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInFailureMechanismItem_GeneralValidationFalseAdditionalValidationNull_CreatesDisabledItemAndSetGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => null);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.ValidateAll_No_calculations_to_validate, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInFailureMechanismItem_GeneralValidationTrueAdditionalValidationContainsMessage_CreatesDisabledItemAndSetMessageInTooltip()
+ {
+ // Setup
+ var calculation = new TestCalculation();
+
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculation
+ });
+
+ var errorMessage = "Additional check failed.";
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => errorMessage);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(errorMessage, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInFailureMechanismItem_GeneralValidationFalseAdditionalValidationContainsMessage_CreatesDisabledItemAndSetGeneralValidationMessageTooltip()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism(Enumerable.Empty());
+
+ var errorMessage = "Additional check failed.";
+
+ // Call
+ StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, null, fm => errorMessage);
+
+ // Assert
+ Assert.AreEqual(RingtoetsFormsResources.Validate_all, toolStripItem.Text);
+ Assert.AreEqual(RingtoetsFormsResources.ValidateAll_No_calculations_to_validate, toolStripItem.ToolTipText);
+ TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ValidateAllIcon, toolStripItem.Image);
+ Assert.IsFalse(toolStripItem.Enabled);
+ }
+
+ [Test]
+ public void CreateValidateAllCalculationsInFailureMechanismItem_PerformClickOnCreatedItem_PerformAllCalculationMethodPerformed()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var calculationMock = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var counter = 0;
+ var failureMechanism = new TestFailureMechanism(new[]
+ {
+ calculationMock
+ });
+ var toolStripItem = RingtoetsContextMenuItemFactory.CreateValidateAllCalculationsInFailureMechanismItem(failureMechanism, fm => counter++, fm => null);
+
+ // Call
+ toolStripItem.PerformClick();
+
+ // Assert
+ Assert.AreEqual(1, counter);
+ mocks.VerifyAll();
+ }
+
+ #endregion
+
# region Nested types
private class TestFailureMechanismContext : FailureMechanismContext
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -re49a3ca2470c9d28e297149111b9adc0cc672b2c -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e49a3ca2470c9d28e297149111b9adc0cc672b2c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -559,15 +559,6 @@
}
///
- /// Looks up a localized string similar to Valideer alle berekeningen binnen deze berekeningsmap..
- ///
- public static string PipingCalculationGroup_Validate_All_ToolTip {
- get {
- return ResourceManager.GetString("PipingCalculationGroup_Validate_All_ToolTip", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Bijdrage [%].
///
public static string PipingCalculationsView_InitializeDataGridView_Contribution {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx
===================================================================
diff -u -re49a3ca2470c9d28e297149111b9adc0cc672b2c -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision e49a3ca2470c9d28e297149111b9adc0cc672b2c)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -424,9 +424,6 @@
Voeg een nieuwe berekening toe aan deze berekeningsmap.
-
- Valideer alle berekeningen binnen deze berekeningsmap.
-
De locatie van het begin van de slootbodem wanneer deze van de kant van de dijk wordt benaderd.
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -ra8354e83db04899a5e94b92c8803d31131a8b480 -rd08c15413bbb6009c6da8ee05833a4c3531b358c
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision a8354e83db04899a5e94b92c8803d31131a8b480)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision d08c15413bbb6009c6da8ee05833a4c3531b358c)
@@ -364,16 +364,14 @@
private ContextMenuStrip FailureMechanismEnabledContextMenuStrip(PipingFailureMechanismContext pipingFailureMechanismContext, object parentData, TreeViewControl treeViewControl)
{
- var validateAllItem = CreateValidateAllItem(pipingFailureMechanismContext.WrappedData);
-
var builder = new RingtoetsContextMenuBuilder(Gui.Get(pipingFailureMechanismContext, treeViewControl));
return builder.AddOpenItem()
.AddSeparator()
.AddToggleRelevancyOfFailureMechanismItem(pipingFailureMechanismContext, RemoveAllViewsForItem)
.AddSeparator()
- .AddCustomItem(validateAllItem)
- .AddPerformAllCalculationsInFailureMechanismItem(pipingFailureMechanismContext, CalculateAll, ValidateAllDataAvailableAndGetErrorMessageForCalculationsInFailureMechanism)
+ .AddValidateAllCalculationsInFailureMechanismItem(pipingFailureMechanismContext.WrappedData, fm => ValidateAll(fm.Calculations.OfType()))
+ .AddPerformAllCalculationsInFailureMechanismItem(pipingFailureMechanismContext, CalculateAll)
.AddClearAllCalculationOutputInFailureMechanismItem(pipingFailureMechanismContext.WrappedData)
.AddSeparator()
.AddImportItem()
@@ -385,12 +383,7 @@
.AddPropertiesItem()
.Build();
}
-
- private string ValidateAllDataAvailableAndGetErrorMessageForCalculationsInFailureMechanism(PipingFailureMechanismContext pipingFailureMechanismContext)
- {
- return ValidateAllDataAvailableAndGetErrorMessage(pipingFailureMechanismContext.WrappedData);
- }
-
+
private void RemoveAllViewsForItem(PipingFailureMechanismContext failureMechanismContext)
{
Gui.ViewCommands.RemoveAllViewsForItem(failureMechanismContext);
@@ -412,26 +405,6 @@
return failureMechanism.Calculations.OfType();
}
- private StrictContextMenuItem CreateValidateAllItem(PipingFailureMechanism failureMechanism)
- {
- var menuItem = new StrictContextMenuItem(
- RingtoetsCommonFormsResources.Validate_all,
- RingtoetsCommonFormsResources.Validate_all_ToolTip,
- RingtoetsCommonFormsResources.ValidateAllIcon,
- (o, args) =>
- {
- ValidateAll(GetAllPipingCalculations(failureMechanism));
- });
-
- if (!GetAllPipingCalculations(failureMechanism).Any())
- {
- menuItem.Enabled = false;
- menuItem.ToolTipText = RingtoetsCommonFormsResources.FailureMechanism_CreateValidateAllItem_No_calculations_to_validate;
- }
-
- return menuItem;
- }
-
private object[] FailureMechanismEnabledChildNodeObjects(PipingFailureMechanismContext pipingFailureMechanismContext)
{
PipingFailureMechanism wrappedData = pipingFailureMechanismContext.WrappedData;
@@ -480,13 +453,8 @@
PipingCalculation calculation = nodeData.WrappedData;
- var validateItem = new StrictContextMenuItem(RingtoetsCommonFormsResources.Validate,
- RingtoetsCommonFormsResources.Validate_ToolTip,
- RingtoetsCommonFormsResources.ValidateIcon,
- (o, args) => { PipingCalculationService.Validate(calculation); });
-
- return builder.AddCustomItem(validateItem)
- .AddPerformCalculationItem(calculation, nodeData, PerformCalculation, ValidateAllDataAvailableAndGetErrorMessageForCalculation)
+ return builder.AddValidateCalculationItem(calculation, c => PipingCalculationService.Validate(c))
+ .AddPerformCalculationItem(calculation, nodeData, PerformCalculation)
.AddClearCalculationOutputItem(calculation)
.AddSeparator()
.AddRenameItem()
@@ -502,16 +470,6 @@
.Build();
}
- private string ValidateAllDataAvailableAndGetErrorMessageForCalculation(PipingCalculationScenarioContext context)
- {
- return ValidateAllDataAvailableAndGetErrorMessage(context.FailureMechanism);
- }
-
- private static string ValidateAllDataAvailableAndGetErrorMessage(PipingFailureMechanism failureMechanism)
- {
- return !failureMechanism.Sections.Any() ? RingtoetsCommonFormsResources.GuiPlugin_AllDataAvailable_No_failure_mechanism_sections_imported : null;
- }
-
private static object[] PipingCalculationContextChildNodeObjects(PipingCalculationScenarioContext pipingCalculationScenarioContext)
{
var childNodes = new List