Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ICalculationContext.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ICalculationContext.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/ICalculationContext.cs (revision b1a215180352084c8f320439c1893c639917f338)
@@ -0,0 +1,47 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Base;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Forms.PresentationObjects
+{
+ ///
+ /// Interface for contexts that wrap a calculation item.
+ ///
+ /// The type of the wrapped calculation item.
+ /// The type of the failure mechanism the wrapped calculation item belongs to.
+ public interface ICalculationContext : IObservable
+ where TCalculationBase : ICalculationBase
+ where TFailureMechanism : IFailureMechanism
+ {
+ ///
+ /// Gets the wrapped calculation item.
+ ///
+ TCalculationBase WrappedData { get; }
+
+ ///
+ /// Gets the failure mechanism the wrapped calculation item belongs to.
+ ///
+ TFailureMechanism FailureMechanism { get; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r3ba42e2c8b6380227f4b2e1d1897135ec962beab -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3ba42e2c8b6380227f4b2e1d1897135ec962beab)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -61,6 +61,24 @@
}
///
+ /// Looks up a localized string similar to Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap..
+ ///
+ public static string Add_calculation_group_to_calculation_group_tooltip {
+ get {
+ return ResourceManager.GetString("Add_calculation_group_to_calculation_group_tooltip", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Voeg een nieuwe berekening toe aan deze berekeningsmap..
+ ///
+ public static string Add_calculation_to_calculation_group_tooltip {
+ get {
+ return ResourceManager.GetString("Add_calculation_to_calculation_group_tooltip", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap AddFolderIcon {
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx
===================================================================
diff -u -r3ba42e2c8b6380227f4b2e1d1897135ec962beab -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 3ba42e2c8b6380227f4b2e1d1897135ec962beab)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -283,4 +283,10 @@
Geeft aan of dit faalmechanisme relevant is of niet.
+
+ Voeg een nieuwe berekening toe aan deze berekeningsmap.
+
+
+ Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r3ba42e2c8b6380227f4b2e1d1897135ec962beab -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 3ba42e2c8b6380227f4b2e1d1897135ec962beab)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -43,6 +43,7 @@
Properties\GlobalAssembly.cs
+
@@ -60,6 +61,7 @@
Resources.resx
+
UserControl
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/TreeNodeInfoFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/TreeNodeInfoFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/TreeNodeInfoFactory.cs (revision b1a215180352084c8f320439c1893c639917f338)
@@ -0,0 +1,285 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.ContextMenu;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.Helpers;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Common.Forms.Properties;
+
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
+
+namespace Ringtoets.Common.Forms.TreeNodeInfos
+{
+ ///
+ /// Factory for creating objects.
+ ///
+ public static class TreeNodeInfoFactory
+ {
+ ///
+ /// Creates a object for a calculation group context of the type .
+ ///
+ /// The type of calculation group context to create a object for.
+ /// The function for obtaining child node objects.
+ /// The action for adding a calculation to the calculation group.
+ /// The gui to use.
+ /// A object.
+ public static TreeNodeInfo CreateCalculationGroupContextTreeNodeInfo(
+ Func childNodeObjects,
+ Action addCalculation,
+ IGui gui)
+ where TCalculationGroupContext : ICalculationContext
+ {
+ return new TreeNodeInfo
+ {
+ Text = context => context.WrappedData.Name,
+ Image = context => Resources.GeneralFolderIcon,
+ EnsureVisibleOnCreate = context => true,
+ ChildNodeObjects = childNodeObjects,
+ ContextMenuStrip = (context, parentData, treeViewControl) => ContextMenuStrip(context, parentData, treeViewControl, addCalculation, gui),
+ CanRename = (context, parentData) => IsNestedGroup(parentData),
+ OnNodeRenamed = (context, newName) =>
+ {
+ context.WrappedData.Name = newName;
+ context.NotifyObservers();
+ },
+ CanRemove = (context, parentData) => IsNestedGroup(parentData),
+ OnNodeRemoved = (context, parentData) =>
+ {
+ var parentGroup = (ICalculationContext) parentData;
+
+ parentGroup.WrappedData.Children.Remove(context.WrappedData);
+ parentGroup.NotifyObservers();
+ },
+ CanDrag = (context, parentData) => IsNestedGroup(parentData),
+ CanInsert = CanDropOrInsert,
+ CanDrop = CanDropOrInsert,
+ OnDrop = OnDrop
+ };
+ }
+
+ private static bool IsNestedGroup(object parentData)
+ {
+ return parentData is ICalculationContext;
+ }
+
+ private static ContextMenuStrip ContextMenuStrip(TCalculationGroupContext nodeData, object parentData, TreeViewControl treeViewControl, Action addCalculation, IGui gui) where TCalculationGroupContext : ICalculationContext
+ {
+ var group = nodeData.WrappedData;
+
+ var addCalculationGroupItem = new StrictContextMenuItem(
+ Resources.CalculationGroup_Add_CalculationGroup,
+ Resources.Add_calculation_group_to_calculation_group_tooltip,
+ Resources.AddFolderIcon,
+ (o, args) =>
+ {
+ var calculation = new CalculationGroup
+ {
+ Name = NamingHelper.GetUniqueName(group.Children, RingtoetsCommonDataResources.CalculationGroup_DefaultName, c => c.Name)
+ };
+ group.Children.Add(calculation);
+ nodeData.WrappedData.NotifyObservers();
+ });
+
+ var addCalculationItem = new StrictContextMenuItem(
+ Resources.CalculationGroup_Add_Calculation,
+ Resources.Add_calculation_to_calculation_group_tooltip,
+ Resources.FailureMechanismIcon,
+ (o, args) => { addCalculation(nodeData); });
+
+ var builder = gui.Get(nodeData, treeViewControl);
+
+ var isNestedGroup = IsNestedGroup(parentData);
+
+ if (!isNestedGroup)
+ {
+ builder
+ .AddOpenItem()
+ .AddSeparator();
+ }
+
+ builder
+ .AddCustomItem(addCalculationGroupItem)
+ .AddCustomItem(addCalculationItem)
+ .AddSeparator();
+
+ if (isNestedGroup)
+ {
+ builder.AddRenameItem();
+ builder.AddDeleteItem();
+ builder.AddSeparator();
+ }
+
+ return builder
+ .AddImportItem()
+ .AddExportItem()
+ .AddSeparator()
+ .AddExpandAllItem()
+ .AddCollapseAllItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build();
+ }
+
+ private static bool CanDropOrInsert(object draggedData, object targetData)
+ {
+ var calculationContext = draggedData as ICalculationContext;
+ return calculationContext != null && ReferenceEquals(calculationContext.FailureMechanism, ((ICalculationContext)targetData).FailureMechanism);
+ }
+
+ private static void OnDrop(object droppedData, object newParentData, object oldParentData, int position, TreeViewControl treeViewControl)
+ {
+ ICalculationBase calculationItem = ((ICalculationContext) droppedData).WrappedData;
+ var originalOwnerContext = oldParentData as ICalculationContext;
+ var targetContext = newParentData as ICalculationContext;
+
+ if (calculationItem != null && originalOwnerContext != null && targetContext != null)
+ {
+ var sourceCalculationGroup = originalOwnerContext.WrappedData;
+ var targetCalculationGroup = targetContext.WrappedData;
+
+ var isMoveWithinSameContainer = ReferenceEquals(sourceCalculationGroup, targetCalculationGroup);
+
+ DroppingCalculationInContainerStrategy dropHandler = GetDragDropStrategy(isMoveWithinSameContainer, sourceCalculationGroup, targetCalculationGroup);
+ dropHandler.Execute(droppedData, calculationItem, position, treeViewControl);
+ }
+ }
+
+ private static DroppingCalculationInContainerStrategy GetDragDropStrategy(bool isMoveWithinSameContainer, CalculationGroup sourceCalculationGroup, CalculationGroup targetCalculationGroup)
+ {
+ return isMoveWithinSameContainer
+ ? (DroppingCalculationInContainerStrategy)new DroppingCalculationWithinSameContainer(sourceCalculationGroup, targetCalculationGroup)
+ : new DroppingCalculationToNewContainer(sourceCalculationGroup, targetCalculationGroup);
+ }
+
+ #region Nested Types: DroppingPipingCalculationInContainerStrategy and implementations
+
+ ///
+ /// Strategy pattern implementation for dealing with drag & dropping a
+ /// onto data.
+ ///
+ private abstract class DroppingCalculationInContainerStrategy
+ {
+ private readonly CalculationGroup sourceCalculationGroup;
+ protected readonly CalculationGroup targetCalculationGroup;
+
+ protected DroppingCalculationInContainerStrategy(CalculationGroup sourceCalculationGroup, CalculationGroup targetCalculationGroup)
+ {
+ this.sourceCalculationGroup = sourceCalculationGroup;
+ this.targetCalculationGroup = targetCalculationGroup;
+ }
+
+ ///
+ /// Perform the drag & drop operation.
+ ///
+ /// The dragged data.
+ /// The calculation item wrapped by .
+ /// The index of the new position within the new owner's collection.
+ /// The tree view control which is at stake.
+ public virtual void Execute(object draggedData, ICalculationBase calculationBase, int newPosition, TreeViewControl treeViewControl)
+ {
+ MoveCalculationItemToNewOwner(calculationBase, newPosition);
+
+ NotifyObservers();
+ }
+
+ ///
+ /// Moves the instance to its new location.
+ ///
+ /// The instance to be relocated.
+ /// The index in the new
+ /// owner within its .
+ protected void MoveCalculationItemToNewOwner(ICalculationBase calculationBase, int position)
+ {
+ sourceCalculationGroup.Children.Remove(calculationBase);
+ targetCalculationGroup.Children.Insert(position, calculationBase);
+ }
+
+ ///
+ /// Notifies observers of the change in state.
+ ///
+ protected virtual void NotifyObservers()
+ {
+ sourceCalculationGroup.NotifyObservers();
+ }
+ }
+
+ ///
+ /// Strategy implementation for rearranging the order of an
+ /// within a through a drag & drop action.
+ ///
+ private class DroppingCalculationWithinSameContainer : DroppingCalculationInContainerStrategy
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The calculation group that is the target of the drag & drop operation.
+ /// The calculation group that is the original owner of the dragged item.
+ public DroppingCalculationWithinSameContainer(CalculationGroup sourceCalculationGroup, CalculationGroup targetCalculationGroup) :
+ base(sourceCalculationGroup, targetCalculationGroup) { }
+ }
+
+ ///
+ /// Strategy implementation for moving an from
+ /// one to another using a drag & drop action.
+ ///
+ private class DroppingCalculationToNewContainer : DroppingCalculationInContainerStrategy
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The calculation group that is the original owner of the dragged item.
+ /// The calculation group that is the target of the drag & drop operation.
+ public DroppingCalculationToNewContainer(CalculationGroup sourceCalculationGroup, CalculationGroup targetCalculationGroup) :
+ base(sourceCalculationGroup, targetCalculationGroup) { }
+
+ public override void Execute(object draggedData, ICalculationBase calculationBase, int newPosition, TreeViewControl treeViewControl)
+ {
+ MoveCalculationItemToNewOwner(calculationBase, newPosition);
+
+ NotifyObservers();
+
+ // Try to start a name edit action when an item with the same name was already present
+ if (targetCalculationGroup.Children.Except(new[]
+ {
+ calculationBase
+ }).Any(c => c.Name.Equals(calculationBase.Name)))
+ {
+ treeViewControl.TryRenameNodeForData(draggedData);
+ }
+ }
+
+ protected override void NotifyObservers()
+ {
+ base.NotifyObservers();
+ targetCalculationGroup.NotifyObservers();
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationContext.cs
===================================================================
diff -u -r11e4cd9d892da070b3374027f419d2abc3ea4df9 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationContext.cs (.../GrassCoverErosionInwardsCalculationContext.cs) (revision 11e4cd9d892da070b3374027f419d2abc3ea4df9)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationContext.cs (.../GrassCoverErosionInwardsCalculationContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -21,6 +21,7 @@
using System;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.GrassCoverErosionInwards.Data;
namespace Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects
@@ -29,7 +30,7 @@
/// Presentation object for all data required to configure an instance of
/// in order to prepare it for performing a calculation.
///
- public class GrassCoverErosionInwardsCalculationContext : GrassCoverErosionInwardsContext
+ public class GrassCoverErosionInwardsCalculationContext : GrassCoverErosionInwardsContext, ICalculationContext
{
///
/// Creates a new instance of .
@@ -39,18 +40,6 @@
/// The assessment section which the calculation belongs to.
/// Thrown when any input parameter is null.
public GrassCoverErosionInwardsCalculationContext(GrassCoverErosionInwardsCalculation calculation, GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
- : base(calculation, assessmentSection)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException("failureMechanism");
- }
- GrassCoverErosionInwardsFailureMechanism = failureMechanism;
- }
-
- ///
- /// Gets the failure mechanism which the context belongs to.
- ///
- public GrassCoverErosionInwardsFailureMechanism GrassCoverErosionInwardsFailureMechanism { get; private set; }
+ : base(calculation, failureMechanism, assessmentSection) {}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContext.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContext.cs (.../GrassCoverErosionInwardsCalculationGroupContext.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContext.cs (.../GrassCoverErosionInwardsCalculationGroupContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -19,42 +19,26 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.GrassCoverErosionInwards.Data;
-using Ringtoets.GrassCoverErosionInwards.Forms.Properties;
namespace Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects
{
///
/// Presentation object for all data required to configure an instance of
/// in order be able to create configurable grass cover erosion inwards calculations.
///
- public class GrassCoverErosionInwardsCalculationGroupContext : GrassCoverErosionInwardsContext
+ public class GrassCoverErosionInwardsCalculationGroupContext : GrassCoverErosionInwardsContext, ICalculationContext
{
///
/// Creates a new instance of .
///
/// The instance wrapped by this context object.
- /// The failure mechanism which the context belongs to.
+ /// The failure mechanism which the context belongs to.
/// The assessment section which the context belongs to.
- public GrassCoverErosionInwardsCalculationGroupContext(CalculationGroup calculationsGroup, GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwardsFailureMechanism, IAssessmentSection assessmentSection)
- : base(calculationsGroup, assessmentSection)
- {
- if (grassCoverErosionInwardsFailureMechanism == null)
- {
- var message = string.Format(Resources.GrassCoverErosionInwardsContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.GrassCoverErosionInwardsContext_DataDescription_GrassCoverErosionInwardsFailureMechanism);
- throw new ArgumentNullException("grassCoverErosionInwardsFailureMechanism", message);
- }
-
- GrassCoverErosionInwardsFailureMechanism = grassCoverErosionInwardsFailureMechanism;
- }
-
- ///
- /// Gets the which the belongs to.
- ///
- public GrassCoverErosionInwardsFailureMechanism GrassCoverErosionInwardsFailureMechanism { get; private set; }
+ public GrassCoverErosionInwardsCalculationGroupContext(CalculationGroup calculationsGroup, GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ : base(calculationsGroup, failureMechanism, assessmentSection) {}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsContext.cs
===================================================================
diff -u -r510b9a49197f9bba205844d0311092236356207c -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsContext.cs (.../GrassCoverErosionInwardsContext.cs) (revision 510b9a49197f9bba205844d0311092236356207c)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsContext.cs (.../GrassCoverErosionInwardsContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -23,6 +23,7 @@
using Core.Common.Base;
using Core.Common.Controls.PresentationObjects;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionInwards.Forms.Properties;
namespace Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects
@@ -37,23 +38,40 @@
/// Initializes a new instance of the class.
///
/// The concrete data instance wrapped by this context object.
+ /// The failure mechanism which the context belongs to.
/// The assessment section which the context belongs to.
/// When any input parameter is null.
protected GrassCoverErosionInwardsContext(
- T wrappedData, IAssessmentSection assessmentSection)
+ T wrappedData,
+ GrassCoverErosionInwardsFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
: base(wrappedData)
{
+ if (failureMechanism == null)
+ {
+ var message = String.Format(Resources.GrassCoverErosionInwardsContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
+ Resources.GrassCoverErosionInwardsContext_DataDescription_GrassCoverErosionInwardsFailureMechanism);
+
+ throw new ArgumentNullException("failureMechanism", message);
+ }
+
if (assessmentSection == null)
{
var message = String.Format(Resources.GrassCoverErosionInwardsContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
Resources.GrassCoverErosionInwardsContext_DataDescription_AssessmentSection);
throw new ArgumentNullException("assessmentSection", message);
}
+ FailureMechanism = failureMechanism;
AssessmentSection = assessmentSection;
}
///
+ /// Gets the failure mechanism which the context belongs to.
+ ///
+ public GrassCoverErosionInwardsFailureMechanism FailureMechanism { get; private set; }
+
+ ///
/// Gets the assessment section which the failure mechanism context belongs to.
///
public IAssessmentSection AssessmentSection { get; private set; }
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsInputContext.cs
===================================================================
diff -u -r11e4cd9d892da070b3374027f419d2abc3ea4df9 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsInputContext.cs (.../GrassCoverErosionInwardsInputContext.cs) (revision 11e4cd9d892da070b3374027f419d2abc3ea4df9)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsInputContext.cs (.../GrassCoverErosionInwardsInputContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -34,14 +34,14 @@
///
/// The grass cover erosion inwards input instance wrapped by this context object.
/// The calculation item the belongs to.
- /// The failure mechanism which the context belongs to.
+ /// The failure mechanism which the context belongs to.
/// The assessment section which the context belongs to.
/// Thrown when any input parameter is null.
public GrassCoverErosionInwardsInputContext(GrassCoverErosionInwardsInput input,
ICalculation calculation,
- GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwardsFailureMechanism,
+ GrassCoverErosionInwardsFailureMechanism failureMechanism,
IAssessmentSection assessmentSection)
- : base(input, assessmentSection)
+ : base(input, failureMechanism, assessmentSection)
{
if (calculation == null)
{
@@ -50,27 +50,13 @@
throw new ArgumentNullException("calculation", message);
}
- if (grassCoverErosionInwardsFailureMechanism == null)
- {
- var message = String.Format(Resources.GrassCoverErosionInwardsContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.GrassCoverErosionInwardsContext_DataDescription_GrassCoverErosionInwardsFailureMechanism);
- throw new ArgumentNullException("grassCoverErosionInwardsFailureMechanism", message);
- }
-
Calculation = calculation;
-
- GrassCoverErosionInwardsFailureMechanism = grassCoverErosionInwardsFailureMechanism;
}
///
/// Gets the calculation item which the context belongs to.
///
public ICalculation Calculation { get; private set; }
-
- ///
- /// Gets the failure mechanism which the context belongs to.
- ///
- public GrassCoverErosionInwardsFailureMechanism GrassCoverErosionInwardsFailureMechanism { get; private set; }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs
===================================================================
diff -u -re3912b8e6d94f1d0e9c765ba8ec18ed29e8484db -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision e3912b8e6d94f1d0e9c765ba8ec18ed29e8484db)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -70,22 +70,7 @@
FailureMechanismContextMenuStrip,
Gui);
- yield return new TreeNodeInfo
- {
- Text = grassCoverErosionInwardsFailureMechanismContext => grassCoverErosionInwardsFailureMechanismContext.WrappedData.Name,
- Image = grassCoverErosionInwardsCalculationGroupContext => RingtoetsCommonFormsResources.GeneralFolderIcon,
- EnsureVisibleOnCreate = grassCoverErosionInwardsCalculationGroupContext => true,
- ChildNodeObjects = CalculationGroupContextChildNodeObjects,
- ContextMenuStrip = CalculationGroupContextContextMenuStrip,
- CanRename = CalculationGroupContextCanRename,
- OnNodeRenamed = CalculationGroupContextOnNodeRenamed,
- CanRemove = CalculationGroupContextCanRemove,
- OnNodeRemoved = CalculationGroupContextOnNodeRemoved,
- CanDrag = CalculationGroupContextCanDrag,
- CanDrop = CalculationGroupContextCanDropOrCanInsert,
- CanInsert = CalculationGroupContextCanDropOrCanInsert,
- OnDrop = CalculationGroupContextOnDrop
- };
+ yield return TreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(CalculationGroupContextChildNodeObjects, context => AddCalculation(context.FailureMechanism, context.WrappedData), Gui);
yield return new TreeNodeInfo
{
@@ -127,7 +112,7 @@
new CommentContext(calculationContext.WrappedData),
new GrassCoverErosionInwardsInputContext(calculationContext.WrappedData.InputParameters,
calculationContext.WrappedData,
- calculationContext.GrassCoverErosionInwardsFailureMechanism,
+ calculationContext.FailureMechanism,
calculationContext.AssessmentSection)
};
@@ -334,13 +319,13 @@
if (calculation != null)
{
childNodeObjects.Add(new GrassCoverErosionInwardsCalculationContext(calculation,
- nodeData.GrassCoverErosionInwardsFailureMechanism,
+ nodeData.FailureMechanism,
nodeData.AssessmentSection));
}
else if (group != null)
{
childNodeObjects.Add(new GrassCoverErosionInwardsCalculationGroupContext(group,
- nodeData.GrassCoverErosionInwardsFailureMechanism,
+ nodeData.FailureMechanism,
nodeData.AssessmentSection));
}
else
@@ -352,273 +337,6 @@
return childNodeObjects.ToArray();
}
- private ContextMenuStrip CalculationGroupContextContextMenuStrip(GrassCoverErosionInwardsCalculationGroupContext nodeData, object parentData, TreeViewControl treeViewControl)
- {
- var group = nodeData.WrappedData;
-
- var addCalculationGroupItem = new StrictContextMenuItem(
- RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup,
- RingtoetsCommonFormsResources.FailureMechanism_Add_CalculationGroup_Tooltip,
- RingtoetsCommonFormsResources.AddFolderIcon,
- (o, args) =>
- {
- var calculation = new CalculationGroup
- {
- Name = NamingHelper.GetUniqueName(group.Children, RingtoetsCommonDataResources.CalculationGroup_DefaultName, c => c.Name)
- };
- group.Children.Add(calculation);
- nodeData.WrappedData.NotifyObservers();
- });
-
- var addCalculationItem = new StrictContextMenuItem(
- RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation,
- GrassCoverErosionInwardsFormsResources.GrassCoverErosionInwardsFailureMechanism_Add_GrassCoverErosionInwardsCalculation_Tooltip,
- GrassCoverErosionInwardsFormsResources.CalculationIcon,
- (o, args) => { AddCalculation(nodeData.GrassCoverErosionInwardsFailureMechanism, group); });
-
- var builder = Gui.Get(nodeData, treeViewControl);
-
- if (parentData is GrassCoverErosionInwardsFailureMechanismContext)
- {
- builder
- .AddOpenItem()
- .AddSeparator();
- }
-
- builder
- .AddCustomItem(addCalculationGroupItem)
- .AddCustomItem(addCalculationItem)
- .AddSeparator();
-
- var isRenamable = CalculationGroupContextCanRename(nodeData, parentData);
- var isRemovable = CalculationGroupContextCanRemove(nodeData, parentData);
-
- if (isRenamable)
- {
- builder.AddRenameItem();
- }
- if (isRemovable)
- {
- builder.AddDeleteItem();
- }
-
- if (isRemovable || isRenamable)
- {
- builder.AddSeparator();
- }
-
- return builder
- .AddImportItem()
- .AddExportItem()
- .AddSeparator()
- .AddExpandAllItem()
- .AddCollapseAllItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build();
- }
-
- private bool CalculationGroupContextCanRename(GrassCoverErosionInwardsCalculationGroupContext nodeData, object parentData)
- {
- return !(parentData is GrassCoverErosionInwardsFailureMechanismContext);
- }
-
- private void CalculationGroupContextOnNodeRenamed(GrassCoverErosionInwardsCalculationGroupContext nodeData, string newName)
- {
- nodeData.WrappedData.Name = newName;
- nodeData.NotifyObservers();
- }
-
- private bool CalculationGroupContextCanRemove(GrassCoverErosionInwardsCalculationGroupContext nodeData, object parentNodeData)
- {
- var group = parentNodeData as GrassCoverErosionInwardsCalculationGroupContext;
- return group != null && group.WrappedData.Children.Contains(nodeData.WrappedData);
- }
-
- private void CalculationGroupContextOnNodeRemoved(GrassCoverErosionInwardsCalculationGroupContext nodeData, object parentNodeData)
- {
- var group = parentNodeData as GrassCoverErosionInwardsCalculationGroupContext;
- if (group != null)
- {
- group.WrappedData.Children.Remove(nodeData.WrappedData);
- group.NotifyObservers();
- }
- }
-
- private bool CalculationGroupContextCanDrag(GrassCoverErosionInwardsCalculationGroupContext nodeData, object parentData)
- {
- return !(parentData is GrassCoverErosionInwardsFailureMechanismContext);
- }
-
- private bool CalculationGroupContextCanDropOrCanInsert(object draggedData, object targetData)
- {
- return GetAsICalculationItem(draggedData) != null && NodesHaveSameParentFailureMechanism(draggedData, targetData);
- }
-
- private static ICalculationBase GetAsICalculationItem(object item)
- {
- var calculationContext = item as GrassCoverErosionInwardsCalculationContext;
- if (calculationContext != null)
- {
- return calculationContext.WrappedData;
- }
-
- var groupContext = item as GrassCoverErosionInwardsCalculationGroupContext;
- return groupContext != null ? groupContext.WrappedData : null;
- }
-
- private bool NodesHaveSameParentFailureMechanism(object draggedData, object targetData)
- {
- var sourceFailureMechanism = GetParentFailureMechanism(draggedData);
- var targetFailureMechanism = GetParentFailureMechanism(targetData);
-
- return ReferenceEquals(sourceFailureMechanism, targetFailureMechanism);
- }
-
- private static GrassCoverErosionInwardsFailureMechanism GetParentFailureMechanism(object data)
- {
- var calculationContext = data as GrassCoverErosionInwardsCalculationContext;
- if (calculationContext != null)
- {
- return calculationContext.GrassCoverErosionInwardsFailureMechanism;
- }
-
- var groupContext = data as GrassCoverErosionInwardsCalculationGroupContext;
- return groupContext != null ? groupContext.GrassCoverErosionInwardsFailureMechanism : null;
- }
-
- private void CalculationGroupContextOnDrop(object droppedData, object newParentData, object oldParentData, int position, TreeViewControl treeViewControl)
- {
- ICalculationBase calculationItem = GetAsICalculationItem(droppedData);
- var originalOwnerContext = oldParentData as GrassCoverErosionInwardsCalculationGroupContext;
- var target = newParentData as GrassCoverErosionInwardsCalculationGroupContext;
-
- if (calculationItem != null && originalOwnerContext != null && target != null)
- {
- var isMoveWithinSameContainer = ReferenceEquals(originalOwnerContext, target);
-
- DroppingCalculationInContainerStrategy dropHandler = GetDragDropStrategy(isMoveWithinSameContainer, originalOwnerContext, target);
- dropHandler.Execute(droppedData, calculationItem, position, treeViewControl);
- }
- }
-
- private DroppingCalculationInContainerStrategy GetDragDropStrategy(bool isMoveWithinSameContainer, GrassCoverErosionInwardsCalculationGroupContext originalOwnerContext, GrassCoverErosionInwardsCalculationGroupContext target)
- {
- return isMoveWithinSameContainer
- ? (DroppingCalculationInContainerStrategy) new DroppingCalculationWithinSameContainer(originalOwnerContext, target)
- : new DroppingCalculationToNewContainer(originalOwnerContext, target);
- }
-
- #region Nested Types: DroppingPipingCalculationInContainerStrategy and implementations
-
- ///
- /// Strategy pattern implementation for dealing with drag & dropping a
- /// onto data.
- ///
- private abstract class DroppingCalculationInContainerStrategy
- {
- protected readonly GrassCoverErosionInwardsCalculationGroupContext target;
- private readonly GrassCoverErosionInwardsCalculationGroupContext originalOwnerContext;
-
- protected DroppingCalculationInContainerStrategy(GrassCoverErosionInwardsCalculationGroupContext originalOwnerContext, GrassCoverErosionInwardsCalculationGroupContext target)
- {
- this.originalOwnerContext = originalOwnerContext;
- this.target = target;
- }
-
- ///
- /// Perform the drag & drop operation.
- ///
- /// The dragged data.
- /// The calculation item wrapped by .
- /// The index of the new position within the new owner's collection.
- /// The tree view control which is at stake.
- public virtual void Execute(object draggedData, ICalculationBase calculationBase, int newPosition, TreeViewControl treeViewControl)
- {
- MoveCalculationItemToNewOwner(calculationBase, newPosition);
-
- NotifyObservers();
- }
-
- ///
- /// Moves the instance to its new location.
- ///
- /// The instance to be relocated.
- /// The index in the new
- /// owner within its .
- protected void MoveCalculationItemToNewOwner(ICalculationBase calculationBase, int position)
- {
- originalOwnerContext.WrappedData.Children.Remove(calculationBase);
- target.WrappedData.Children.Insert(position, calculationBase);
- }
-
- ///
- /// Notifies observers of the change in state.
- ///
- protected virtual void NotifyObservers()
- {
- originalOwnerContext.NotifyObservers();
- }
- }
-
- ///
- /// Strategy implementation for rearranging the order of an
- /// within a through a drag & drop action.
- ///
- private class DroppingCalculationWithinSameContainer : DroppingCalculationInContainerStrategy
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The calculation group context that is
- /// the original owner of the dragged item.
- /// The calculation group context that is the target
- /// of the drag & drop operation.
- public DroppingCalculationWithinSameContainer(GrassCoverErosionInwardsCalculationGroupContext originalOwnerContext, GrassCoverErosionInwardsCalculationGroupContext target) :
- base(originalOwnerContext, target) {}
- }
-
- ///
- /// Strategy implementation for moving an from
- /// one to another using a drag & drop action.
- ///
- private class DroppingCalculationToNewContainer : DroppingCalculationInContainerStrategy
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The calculation group context that is
- /// the original owner of the dragged item.
- /// The calculation group context that is the target
- /// of the drag & drop operation.
- public DroppingCalculationToNewContainer(GrassCoverErosionInwardsCalculationGroupContext originalOwnerContext, GrassCoverErosionInwardsCalculationGroupContext target) :
- base(originalOwnerContext, target) {}
-
- public override void Execute(object draggedData, ICalculationBase calculationBase, int newPosition, TreeViewControl treeViewControl)
- {
- MoveCalculationItemToNewOwner(calculationBase, newPosition);
-
- NotifyObservers();
-
- // Try to start a name edit action when an item with the same name was already present
- if (target.WrappedData.Children.Except(new[]
- {
- calculationBase
- }).Any(c => c.Name.Equals(calculationBase.Name)))
- {
- treeViewControl.TryRenameNodeForData(draggedData);
- }
- }
-
- protected override void NotifyObservers()
- {
- base.NotifyObservers();
- target.NotifyObservers();
- }
- }
-
- # endregion
-
#endregion
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs
===================================================================
diff -u -r392c4a63ebfaee062d8dc611ecf41881ac1fe3a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs (.../GrassCoverErosionInwardsCalculationContextTest.cs) (revision 392c4a63ebfaee062d8dc611ecf41881ac1fe3a5)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationContextTest.cs (.../GrassCoverErosionInwardsCalculationContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -53,7 +53,7 @@
// Assert
Assert.AreEqual(calculationMock, context.WrappedData);
- Assert.AreEqual(failureMechanismMock, context.GrassCoverErosionInwardsFailureMechanism);
+ Assert.AreEqual(failureMechanismMock, context.FailureMechanism);
Assert.AreEqual(assessmentSectionMock, context.AssessmentSection);
mocksRepository.VerifyAll();
}
@@ -74,39 +74,5 @@
Assert.AreEqual("wrappedData", exception.ParamName);
mocksRepository.VerifyAll();
}
-
- [Test]
- public void Constructor_NullFailureMechanism_ThrowsArgumentNullException()
- {
- // Setup
- var calculationMock = mocksRepository.StrictMock(new GeneralGrassCoverErosionInwardsInput());
- var assessmentSectionMock = mocksRepository.StrictMock();
- mocksRepository.ReplayAll();
-
- // Call
- TestDelegate test = () => new GrassCoverErosionInwardsCalculationContext(calculationMock, null, assessmentSectionMock);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("failureMechanism", exception.ParamName);
- mocksRepository.VerifyAll();
- }
-
- [Test]
- public void Constructor_NullAssessmentSection_ThrowsArgumentNullException()
- {
- // Setup
- var calculationMock = mocksRepository.StrictMock(new GeneralGrassCoverErosionInwardsInput());
- var failureMechanismMock = mocksRepository.StrictMock();
- mocksRepository.ReplayAll();
-
- // Call
- TestDelegate test = () => new GrassCoverErosionInwardsCalculationContext(calculationMock, failureMechanismMock, null);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("assessmentSection", exception.ParamName);
- mocksRepository.VerifyAll();
- }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContextTest.cs
===================================================================
diff -u -r79f417a64ad7845136da14dc776b14503797347e -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContextTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTest.cs) (revision 79f417a64ad7845136da14dc776b14503797347e)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationGroupContextTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -19,9 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using Core.Common.Base;
-using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
@@ -58,44 +56,12 @@
Assert.IsInstanceOf(groupContext);
Assert.IsInstanceOf>(groupContext);
Assert.AreSame(calculationGroup, groupContext.WrappedData);
- Assert.AreSame(failureMechanismMock, groupContext.GrassCoverErosionInwardsFailureMechanism);
+ Assert.AreSame(failureMechanismMock, groupContext.FailureMechanism);
Assert.AreSame(assessmentSectionMock, groupContext.AssessmentSection);
mockRepository.VerifyAll();
}
[Test]
- public void ParameteredConstructor_FailureMechanismIsNull_ThrowArgumentNullException()
- {
- // Setup
- var calculationGroup = new CalculationGroup();
- var assessmentSectionMock = mockRepository.StrictMock();
- mockRepository.ReplayAll();
-
- // Call
- TestDelegate call = () => new GrassCoverErosionInwardsCalculationGroupContext(calculationGroup, null, assessmentSectionMock);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het grasbekleding erosie kruin en binnentalud faalmechanisme mag niet 'null' zijn.");
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
- {
- // Setup
- var calculationGroup = new CalculationGroup();
- var failureMechanismMock = mockRepository.StrictMock();
- mockRepository.ReplayAll();
-
- // Call
- TestDelegate call = () => new GrassCoverErosionInwardsCalculationGroupContext(calculationGroup, failureMechanismMock, null);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn.");
- mockRepository.VerifyAll();
- }
-
- [Test]
public void Attach_Observer_ObserverAttachedToCalculationGroup()
{
// Setup
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs
===================================================================
diff -u -rabb2667229e96d5b8158981c890a5c7046e9ca66 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs (.../GrassCoverErosionInwardsContextTest.cs) (revision abb2667229e96d5b8158981c890a5c7046e9ca66)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs (.../GrassCoverErosionInwardsContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -21,9 +21,11 @@
using System;
using Core.Common.Base;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PresentationObjects
@@ -44,17 +46,19 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var target = new ObservableObject();
// Call
- var context = new SimpleGrassCoverErosionInwardsContext(target, assessmentSectionMock);
+ var context = new SimpleGrassCoverErosionInwardsContext(target, failureMechanismMock, assessmentSectionMock);
// Assert
Assert.IsInstanceOf(context);
-
Assert.AreSame(target, context.WrappedData);
+ Assert.AreSame(assessmentSectionMock, context.AssessmentSection);
+ Assert.AreSame(failureMechanismMock, context.FailureMechanism);
mockRepository.VerifyAll();
}
@@ -64,10 +68,12 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
// Call
TestDelegate call = () => new SimpleGrassCoverErosionInwardsContext(null,
+ failureMechanismMock,
assessmentSectionMock);
// Assert
@@ -81,17 +87,53 @@
}
[Test]
+ public void ParameteredConstructor_FailureMechanismIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var assessmentSectionMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var observableObject = new ObservableObject();
+
+ // Call
+ TestDelegate call = () => new SimpleGrassCoverErosionInwardsContext(observableObject, null, assessmentSectionMock);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het grasbekleding erosie kruin en binnentalud faalmechanisme mag niet 'null' zijn.");
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var failureMechanismMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var observableObject = new ObservableObject();
+
+ // Call
+ TestDelegate call = () => new SimpleGrassCoverErosionInwardsContext(observableObject, failureMechanismMock, null);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn.");
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Attach_Observer_ObserverAttachedToWrappedObject()
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
var observerMock = mockRepository.StrictMock();
observerMock.Expect(o => o.UpdateObserver());
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -107,12 +149,14 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
var observerMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Precondition
context.Attach(observerMock);
@@ -130,13 +174,15 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
var observerMock = mockRepository.StrictMock();
observerMock.Expect(o => o.UpdateObserver());
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Precondition
@@ -154,10 +200,12 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -173,10 +221,12 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -192,13 +242,16 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
var otherContext = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -216,14 +269,17 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var otherObservableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
var otherContext = new SimpleGrassCoverErosionInwardsContext(otherObservableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -241,14 +297,17 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
var observableStub = mockRepository.Stub();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
var otherContext = new SimpleGrassCoverErosionInwardsContext(observableStub,
+ failureMechanismMock,
assessmentSectionMock);
// Call
@@ -266,13 +325,16 @@
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ var failureMechanismMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
var otherContext = new SimpleGrassCoverErosionInwardsContext(observableObject,
+ failureMechanismMock,
assessmentSectionMock);
// Precondition
Assert.True(context.Equals(otherContext));
@@ -290,8 +352,8 @@
private class SimpleGrassCoverErosionInwardsContext : GrassCoverErosionInwardsContext where T : IObservable
{
- public SimpleGrassCoverErosionInwardsContext(T target, IAssessmentSection assessmentSection)
- : base(target, assessmentSection) {}
+ public SimpleGrassCoverErosionInwardsContext(T target, GrassCoverErosionInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ : base(target, failureMechanism, assessmentSection) {}
}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs
===================================================================
diff -u -r392c4a63ebfaee062d8dc611ecf41881ac1fe3a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs (.../GrassCoverErosionInwardsInputContextTest.cs) (revision 392c4a63ebfaee062d8dc611ecf41881ac1fe3a5)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsInputContextTest.cs (.../GrassCoverErosionInwardsInputContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -59,7 +59,7 @@
// Assert
Assert.AreEqual(inputMock, context.WrappedData);
Assert.AreEqual(calculationMock, context.Calculation);
- Assert.AreEqual(failureMechanismMock, context.GrassCoverErosionInwardsFailureMechanism);
+ Assert.AreEqual(failureMechanismMock, context.FailureMechanism);
Assert.AreEqual(assessmentSectionMock, context.AssessmentSection);
mocksRepository.VerifyAll();
}
@@ -101,44 +101,5 @@
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message);
mocksRepository.VerifyAll();
}
-
- [Test]
- public void Constructor_NullFailureMechanism_ThrowsArgumentNullException()
- {
- // Setup
- var generalInput = new GeneralGrassCoverErosionInwardsInput();
- var inputMock = mocksRepository.StrictMock(generalInput);
- var calculationMock = mocksRepository.StrictMock();
- var assessmentSectionMock = mocksRepository.StrictMock();
- mocksRepository.ReplayAll();
-
- // Call
- TestDelegate test = () => new GrassCoverErosionInwardsInputContext(inputMock, calculationMock, null, assessmentSectionMock);
-
- // Assert
- var message = String.Format(Resources.GrassCoverErosionInwardsContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.GrassCoverErosionInwardsContext_DataDescription_GrassCoverErosionInwardsFailureMechanism);
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message);
- mocksRepository.VerifyAll();
- }
-
- [Test]
- public void Constructor_NullAssessmentSection_ThrowsArgumentNullException()
- {
- // Setup
- var generalInput = new GeneralGrassCoverErosionInwardsInput();
- var inputMock = mocksRepository.StrictMock(generalInput);
- var calculationMock = mocksRepository.StrictMock();
- var failureMechanismMock = mocksRepository.StrictMock();
- mocksRepository.ReplayAll();
-
- // Call
- TestDelegate test = () => new GrassCoverErosionInwardsInputContext(inputMock, calculationMock, failureMechanismMock, null);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("assessmentSection", exception.ParamName);
- mocksRepository.VerifyAll();
- }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r392c4a63ebfaee062d8dc611ecf41881ac1fe3a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 392c4a63ebfaee062d8dc611ecf41881ac1fe3a5)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -45,15 +45,21 @@
[TestFixture]
public class GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest
{
+ private IGui gui;
+ private TreeNodeInfo info;
private MockRepository mocks;
private GrassCoverErosionInwardsGuiPlugin plugin;
- private TreeNodeInfo info;
[SetUp]
public void SetUp()
{
mocks = new MockRepository();
- plugin = new GrassCoverErosionInwardsGuiPlugin();
+ gui = mocks.StrictMock();
+ plugin = new GrassCoverErosionInwardsGuiPlugin
+ {
+ Gui = gui
+ };
+
info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationGroupContext));
}
@@ -173,7 +179,7 @@
Assert.AreEqual(group.Children.Count, children.Length);
var calculationGroupContext = (GrassCoverErosionInwardsCalculationGroupContext) children[0];
Assert.AreSame(childGroup, calculationGroupContext.WrappedData);
- Assert.AreSame(failureMechanismMock, calculationGroupContext.GrassCoverErosionInwardsFailureMechanism);
+ Assert.AreSame(failureMechanismMock, calculationGroupContext.FailureMechanism);
Assert.AreSame(assessmentSectionMock, calculationGroupContext.AssessmentSection);
Assert.AreSame(calculationItem, children[1]);
var calculationContext = (GrassCoverErosionInwardsCalculationContext) children[2];
@@ -185,7 +191,6 @@
public void ContextmenuStrip_FailureMechanismContextParent_ReturnContextMenuWithoutRenameRemove()
{
// Setup
- var gui = mocks.StrictMock();
var group = new CalculationGroup();
var failureMechanismMock = mocks.StrictMock();
@@ -209,8 +214,6 @@
mocks.ReplayAll();
- plugin.Gui = gui;
-
// Call
ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
@@ -224,11 +227,11 @@
false);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndex + mainCalculationGroupContextItemOffset,
RingtoetsFormsResources.CalculationGroup_Add_CalculationGroup,
- "Voeg een nieuwe berekeningsmap toe aan dit faalmechanisme.",
+ "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.",
RingtoetsFormsResources.AddFolderIcon);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationItemIndex + mainCalculationGroupContextItemOffset,
RingtoetsFormsResources.CalculationGroup_Add_Calculation,
- "Voeg een nieuwe grasbekleding erosie kruin en binnentalud berekening toe aan dit faalmechanisme.",
+ "Voeg een nieuwe berekening toe aan deze berekeningsmap.",
GrassCoverErosionInwardsFormResources.CalculationIcon);
TestHelper.AssertContextMenuStripContainsItem(menu, 5,
CoreCommonGuiResources.Import,
@@ -272,7 +275,6 @@
public void ContextmenuStrip_ChildOfGroup_ReturnContextMenuWithAllItems()
{
// Setup
- var gui = mocks.StrictMock();
var parentGroup = new CalculationGroup();
var group = new CalculationGroup();
@@ -303,20 +305,18 @@
mocks.ReplayAll();
- plugin.Gui = gui;
-
// Call
ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
// Assert
Assert.AreEqual(13, menu.Items.Count);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndex,
RingtoetsFormsResources.CalculationGroup_Add_CalculationGroup,
- "Voeg een nieuwe berekeningsmap toe aan dit faalmechanisme.",
+ "Voeg een nieuwe berekeningsmap toe aan deze berekeningsmap.",
RingtoetsFormsResources.AddFolderIcon);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationItemIndex,
RingtoetsFormsResources.CalculationGroup_Add_Calculation,
- "Voeg een nieuwe grasbekleding erosie kruin en binnentalud berekening toe aan dit faalmechanisme.",
+ "Voeg een nieuwe berekening toe aan deze berekeningsmap.",
GrassCoverErosionInwardsFormResources.CalculationIcon);
TestHelper.AssertContextMenuStripContainsItem(menu, 3,
CoreCommonGuiResources.Rename,
@@ -368,14 +368,17 @@
public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers()
{
// Setup
- var gui = mocks.StrictMock();
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
var group = new CalculationGroup();
+ var parentGroup = new CalculationGroup();
var failureMechanismMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group,
failureMechanismMock,
assessmentSectionMock);
+ var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup,
+ failureMechanismMock,
+ assessmentSectionMock);
var calculationItem = mocks.Stub();
calculationItem.Stub(ci => ci.Name).Return("Nieuwe map");
@@ -389,13 +392,11 @@
mocks.ReplayAll();
- plugin.Gui = gui;
-
group.Children.Add(calculationItem);
nodeData.Attach(observer);
- ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
+ ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl);
// Precondition
Assert.AreEqual(1, group.Children.Count);
@@ -417,14 +418,17 @@
public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers()
{
// Setup
- var gui = mocks.StrictMock();
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
var group = new CalculationGroup();
+ var parentGroup = new CalculationGroup();
var failureMechanismMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group,
failureMechanismMock,
assessmentSectionMock);
+ var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup,
+ failureMechanismMock,
+ assessmentSectionMock);
var calculationItem = mocks.Stub();
calculationItem.Stub(ci => ci.Name).Return("Nieuwe berekening");
@@ -438,13 +442,11 @@
mocks.ReplayAll();
- plugin.Gui = gui;
-
group.Children.Add(calculationItem);
nodeData.Attach(observer);
- var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
+ var contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl);
// Precondition
Assert.AreEqual(1, group.Children.Count);
@@ -463,31 +465,35 @@
}
[Test]
- public void CanRenameNode_ParentIsGrassCoverErosionInwardsFailureMechanismContext_ReturnFalse()
+ public void CanRenameNode_ParentIsGrassCoverErosionInwardsCalculationGroupContext_ReturnTrue()
{
// Setup
+ var calculationGroupMock = mocks.StrictMock();
var failureMechanismMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
- var failureMechanismContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
+ var calculationGroupContextMock = mocks.StrictMock(calculationGroupMock, failureMechanismMock, assessmentSectionMock);
mocks.ReplayAll();
// Call
- bool isRenamingAllowed = info.CanRename(null, failureMechanismContextMock);
+ bool isRenamingAllowed = info.CanRename(null, calculationGroupContextMock);
// Assert
- Assert.IsFalse(isRenamingAllowed);
+ Assert.IsTrue(isRenamingAllowed);
mocks.VerifyAll();
}
[Test]
- public void CanRenameNode_EverythingElse_ReturnTrue()
+ public void CanRenameNode_EverythingElse_ReturnFalse()
{
+ // Setup
+ mocks.ReplayAll();
+
// Call
bool isRenamingAllowed = info.CanRename(null, null);
// Assert
- Assert.IsTrue(isRenamingAllowed);
+ Assert.IsFalse(isRenamingAllowed);
mocks.VerifyAll();
}
@@ -572,34 +578,6 @@
}
[Test]
- public void CanRemove_ParentIsGrasCoverErosionInwardsCalculationGroupNotContainingGroup_ReturnFalse()
- {
- // Setup
- var group = new CalculationGroup();
- var failureMechanismMock = mocks.StrictMock();
- var assessmentSectionMock = mocks.StrictMock();
- mocks.ReplayAll();
-
- var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group,
- failureMechanismMock,
- assessmentSectionMock);
-
- var parentGroup = new CalculationGroup();
- var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup,
- failureMechanismMock,
- assessmentSectionMock);
-
- // Precondition
- CollectionAssert.DoesNotContain(parentGroup.Children, group);
-
- // Call
- bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData);
-
- // Assert
- Assert.IsFalse(isRemovalAllowed);
- }
-
- [Test]
public void OnNodeRemoved_ParentIsGrassCoverErosionInwardsCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers()
{
// Setup
@@ -671,7 +649,7 @@
}
[Test]
- public void CanDrag_WithParentNodeDefaultBehavior_ReturnTrue()
+ public void CanDrag_WithoutParentNodeDefaultBehavior_ReturnFalse()
{
// Setup
var group = new CalculationGroup();
@@ -687,29 +665,33 @@
var canDrag = info.CanDrag(groupContext, null);
// Assert
- Assert.IsTrue(canDrag);
+ Assert.IsFalse(canDrag);
}
[Test]
- public void CanDrag_ParentIsGrassCoverErosionInwardsFailureMechanismContext_ReturnFalse()
+ public void CanDrag_ParentIsGrassCoverErosionInwardsCalculationGroupContext_ReturnTrue()
{
// Setup
var group = new CalculationGroup();
+ var parentGroup = new CalculationGroup();
var failureMechanismMock = mocks.StrictMock();
var assessmentSectionMock = mocks.StrictMock();
- var failureMechanismContextMock = mocks.StrictMock(failureMechanismMock, assessmentSectionMock);
mocks.ReplayAll();
var groupContext = new GrassCoverErosionInwardsCalculationGroupContext(group,
failureMechanismMock,
assessmentSectionMock);
+ var parentGroupContext = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup,
+ failureMechanismMock,
+ assessmentSectionMock);
+
// Call
- var canDrag = info.CanDrag(groupContext, failureMechanismContextMock);
+ var canDrag = info.CanDrag(groupContext, parentGroupContext);
// Assert
- Assert.IsFalse(canDrag);
+ Assert.IsTrue(canDrag);
}
[Test]
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismTreeNodeInfoTest.cs
===================================================================
diff -u -r3b29807e8903b2cea3ee7a00a59b2b50f9de1f12 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismTreeNodeInfoTest.cs) (revision 3b29807e8903b2cea3ee7a00a59b2b50f9de1f12)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismTreeNodeInfoTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -139,7 +139,7 @@
var calculationsFolder = (GrassCoverErosionInwardsCalculationGroupContext) children[1];
Assert.AreEqual("Berekeningen", calculationsFolder.WrappedData.Name);
CollectionAssert.AreEqual(failureMechanism.CalculationsGroup.Children, calculationsFolder.WrappedData.Children);
- Assert.AreSame(failureMechanism, calculationsFolder.GrassCoverErosionInwardsFailureMechanism);
+ Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism);
var outputsFolder = (CategoryTreeFolder) children[2];
Assert.AreEqual("Uitvoer", outputsFolder.Name);
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs (.../PipingCalculationGroupContext.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationGroupContext.cs (.../PipingCalculationGroupContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -19,12 +19,11 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Piping.Data;
-using Ringtoets.Piping.Forms.Properties;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Forms.PresentationObjects
@@ -33,7 +32,7 @@
/// Presentation object for all data required to configure an instance of
/// in order be able to create configurable piping calculations.
///
- public class PipingCalculationGroupContext : PipingContext
+ public class PipingCalculationGroupContext : PipingContext, ICalculationContext
{
///
/// Initializes a new instance of the class.
@@ -44,21 +43,6 @@
/// The piping failure mechanism which the piping context belongs to.
/// The assessment section which the piping context belongs to.
public PipingCalculationGroupContext(CalculationGroup calculationGroup, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection)
- : base(calculationGroup, surfaceLines, stochasticSoilModels, assessmentSection)
- {
- if (pipingFailureMechanism == null)
- {
- var message = string.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.PipingContext_DataDescription_PipingFailureMechanism);
- throw new ArgumentNullException("pipingFailureMechanism", message);
- }
-
- PipingFailureMechanism = pipingFailureMechanism;
- }
-
- ///
- /// Gets the PipingFailureMechanism failure mechanism which the PipingFailureMechanism context belongs to.
- ///
- public PipingFailureMechanism PipingFailureMechanism { get; private set; }
+ : base(calculationGroup, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) {}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs (.../PipingCalculationScenarioContext.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingCalculationScenarioContext.cs (.../PipingCalculationScenarioContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -19,11 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Piping.Data;
-using Ringtoets.Piping.Forms.Properties;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Forms.PresentationObjects
@@ -43,21 +41,6 @@
/// The piping failure mechanism which the piping context belongs to.
/// The assessment section which the piping context belongs to.
public PipingCalculationScenarioContext(PipingCalculationScenario calculation, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection)
- : base(calculation, surfaceLines, stochasticSoilModels, assessmentSection)
- {
- if (pipingFailureMechanism == null)
- {
- var message = String.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.PipingContext_DataDescription_PipingFailureMechanism);
- throw new ArgumentNullException("pipingFailureMechanism", message);
- }
-
- PipingFailureMechanism = pipingFailureMechanism;
- }
-
- ///
- /// Gets the PipingFailureMechanism failure mechanism which the PipingFailureMechanism context belongs to.
- ///
- public PipingFailureMechanism PipingFailureMechanism { get; private set; }
+ : base(calculation, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) {}
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs
===================================================================
diff -u -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -45,18 +45,21 @@
/// The concrete data instance wrapped by this context object.
/// The surface lines available within the piping context.
/// The stochastic soil models available within the piping context.
+ /// The piping failure mechanism which the piping context belongs to.
/// The assessment section which the piping context belongs to.
/// When any input parameter is null.
protected PipingContext(
T wrappedData,
IEnumerable surfaceLines,
IEnumerable stochasticSoilModels,
+ PipingFailureMechanism pipingFailureMechanism,
IAssessmentSection assessmentSection) : base(wrappedData)
{
- AssertInputsAreNotNull(surfaceLines, stochasticSoilModels, assessmentSection);
+ AssertInputsAreNotNull(surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection);
AvailablePipingSurfaceLines = surfaceLines;
AvailableStochasticSoilModels = stochasticSoilModels;
+ FailureMechanism = pipingFailureMechanism;
AssessmentSection = assessmentSection;
}
@@ -89,6 +92,11 @@
}
///
+ /// Gets the piping failure mechanism which the piping context belongs to.
+ ///
+ public PipingFailureMechanism FailureMechanism { get; private set; }
+
+ ///
/// Gets the assessment section which the piping context belongs to.
///
public IAssessmentSection AssessmentSection { get; private set; }
@@ -98,9 +106,10 @@
///
/// The surface lines.
/// The soil profiles.
+ /// The piping failure mechanism.
/// The assessment section.
/// When any input parameter is null.
- private static void AssertInputsAreNotNull(object surfaceLines, object soilProfiles, object assessmentSection)
+ private static void AssertInputsAreNotNull(object surfaceLines, object soilProfiles, object pipingFailureMechanism, object assessmentSection)
{
if (surfaceLines == null)
{
@@ -114,6 +123,12 @@
Resources.PipingContext_DataDescription_Soilprofiles);
throw new ArgumentNullException("soilProfiles", message);
}
+ if (pipingFailureMechanism == null)
+ {
+ var message = string.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
+ Resources.PipingContext_DataDescription_PipingFailureMechanism);
+ throw new ArgumentNullException("pipingFailureMechanism", message);
+ }
if (assessmentSection == null)
{
var message = String.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs
===================================================================
diff -u -rec5eeafbbd987b02a9d9c07b7e920c03d567f3f7 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision ec5eeafbbd987b02a9d9c07b7e920c03d567f3f7)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -51,7 +51,7 @@
IEnumerable stochasticSoilModels,
PipingFailureMechanism pipingFailureMechanism,
IAssessmentSection assessmentSection)
- : base(pipingInput, surfaceLines, stochasticSoilModels, assessmentSection)
+ : base(pipingInput, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection)
{
if (calculation == null)
{
@@ -60,26 +60,13 @@
throw new ArgumentNullException("calculation", message);
}
- if (pipingFailureMechanism == null)
- {
- var message = String.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null,
- Resources.PipingContext_DataDescription_PipingFailureMechanism);
- throw new ArgumentNullException("pipingFailureMechanism", message);
- }
-
PipingCalculation = calculation;
- PipingFailureMechanism = pipingFailureMechanism;
}
///
/// Gets the calculation scenario which the piping context belongs to.
///
public PipingCalculationScenario PipingCalculation { get; private set; }
-
- ///
- /// Gets the failure mechanism which the piping context belongs to.
- ///
- public PipingFailureMechanism PipingFailureMechanism { get; private set; }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs
===================================================================
diff -u -rec5eeafbbd987b02a9d9c07b7e920c03d567f3f7 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision ec5eeafbbd987b02a9d9c07b7e920c03d567f3f7)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -176,7 +176,7 @@
data.WrappedData.SurfaceLine = value;
PipingInputService.SetMatchingStochasticSoilModel(data.WrappedData, GetAvailableStochasticSoilModels());
- PipingCalculationScenarioService.SyncCalculationScenarioWithNewSurfaceLine(data.PipingCalculation, data.PipingFailureMechanism, oldSurfaceLine);
+ PipingCalculationScenarioService.SyncCalculationScenarioWithNewSurfaceLine(data.PipingCalculation, data.FailureMechanism, oldSurfaceLine);
data.WrappedData.NotifyObservers();
}
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -ra0c17eeffbe1fc611d12cc9f2f646b769686545e -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision a0c17eeffbe1fc611d12cc9f2f646b769686545e)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -90,13 +90,13 @@
GetViewData = context => context.WrappedData,
GetViewName = (view, calculationGroup) => calculationGroup.Name,
Image = RingtoetsCommonFormsResources.GeneralFolderIcon,
- AdditionalDataCheck = context => context.WrappedData == context.PipingFailureMechanism.CalculationsGroup,
+ AdditionalDataCheck = context => context.WrappedData == context.FailureMechanism.CalculationsGroup,
CloseForData = ClosePipingCalculationsViewForData,
AfterCreate = (view, context) =>
{
view.ApplicationSelection = Gui;
view.AssessmentSection = context.AssessmentSection;
- view.PipingFailureMechanism = context.PipingFailureMechanism;
+ view.PipingFailureMechanism = context.FailureMechanism;
}
};
}
@@ -519,7 +519,7 @@
pipingCalculationScenarioContext.WrappedData,
pipingCalculationScenarioContext.AvailablePipingSurfaceLines,
pipingCalculationScenarioContext.AvailableStochasticSoilModels,
- pipingCalculationScenarioContext.PipingFailureMechanism,
+ pipingCalculationScenarioContext.FailureMechanism,
pipingCalculationScenarioContext.AssessmentSection)
};
@@ -557,7 +557,7 @@
var succesfullyRemovedData = calculationGroupContext.WrappedData.Children.Remove(pipingCalculationScenarioContext.WrappedData);
if (succesfullyRemovedData)
{
- RemoveCalculationFromSectionResult(pipingCalculationScenarioContext.WrappedData, pipingCalculationScenarioContext.PipingFailureMechanism);
+ RemoveCalculationFromSectionResult(pipingCalculationScenarioContext.WrappedData, pipingCalculationScenarioContext.FailureMechanism);
calculationGroupContext.NotifyObservers();
}
}
@@ -592,15 +592,15 @@
childNodeObjects.Add(new PipingCalculationScenarioContext(calculation,
nodeData.AvailablePipingSurfaceLines,
nodeData.AvailableStochasticSoilModels,
- nodeData.PipingFailureMechanism,
+ nodeData.FailureMechanism,
nodeData.AssessmentSection));
}
else if (group != null)
{
childNodeObjects.Add(new PipingCalculationGroupContext(group,
nodeData.AvailablePipingSurfaceLines,
nodeData.AvailableStochasticSoilModels,
- nodeData.PipingFailureMechanism,
+ nodeData.FailureMechanism,
nodeData.AssessmentSection));
}
else
@@ -634,7 +634,7 @@
PipingFormsResources.PipingCalculationGroup_Add_PipingCalculation_ToolTip,
PipingFormsResources.PipingIcon, (o, args) =>
{
- var calculation = new PipingCalculationScenario(nodeData.PipingFailureMechanism.GeneralInput, nodeData.PipingFailureMechanism.NormProbabilityInput)
+ var calculation = new PipingCalculationScenario(nodeData.FailureMechanism.GeneralInput, nodeData.FailureMechanism.NormProbabilityInput)
{
Name = NamingHelper.GetUniqueName(group.Children, PipingDataResources.PipingCalculation_DefaultName, c => c.Name)
};
@@ -744,12 +744,12 @@
var view = new PipingSurfaceLineSelectionDialog(Gui.MainWindow, nodeData.AvailablePipingSurfaceLines);
view.ShowDialog();
- GeneratePipingCalculations(nodeData.WrappedData, view.SelectedSurfaceLines, nodeData.AvailableStochasticSoilModels, nodeData.PipingFailureMechanism.GeneralInput, nodeData.PipingFailureMechanism.NormProbabilityInput);
+ GeneratePipingCalculations(nodeData.WrappedData, view.SelectedSurfaceLines, nodeData.AvailableStochasticSoilModels, nodeData.FailureMechanism.GeneralInput, nodeData.FailureMechanism.NormProbabilityInput);
nodeData.NotifyObservers();
- nodeData.WrappedData.AddCalculationScenariosToFailureMechanismSectionResult(nodeData.PipingFailureMechanism);
- nodeData.PipingFailureMechanism.NotifyObservers();
+ nodeData.WrappedData.AddCalculationScenariosToFailureMechanismSectionResult(nodeData.FailureMechanism);
+ nodeData.FailureMechanism.NotifyObservers();
}
private void GeneratePipingCalculations(CalculationGroup target, IEnumerable surfaceLines, IEnumerable soilModels, GeneralPipingInput generalInput, NormProbabilityPipingInput normProbabilityInput)
@@ -831,7 +831,7 @@
foreach (var calculation in nodeData.WrappedData.GetCalculations().Cast())
{
- RemoveCalculationFromSectionResult(calculation, nodeData.PipingFailureMechanism);
+ RemoveCalculationFromSectionResult(calculation, nodeData.FailureMechanism);
}
group.NotifyObservers();
@@ -878,11 +878,11 @@
var calculationContext = data as PipingCalculationScenarioContext;
if (calculationContext != null)
{
- return calculationContext.PipingFailureMechanism;
+ return calculationContext.FailureMechanism;
}
var groupContext = data as PipingCalculationGroupContext;
- return groupContext != null ? groupContext.PipingFailureMechanism : null;
+ return groupContext != null ? groupContext.FailureMechanism : null;
}
private void PipingCalculationGroupContextOnDrop(object droppedData, object newParentData, object oldParentData, int position, TreeViewControl treeViewControl)
@@ -1017,8 +1017,8 @@
}
}
- # endregion
+ #endregion
- # endregion
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs (.../PipingCalculationGroupContextTest.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationGroupContextTest.cs (.../PipingCalculationGroupContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -1,7 +1,5 @@
-using System;
-using System.Linq;
+using System.Linq;
using Core.Common.Base;
-using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
@@ -44,65 +42,11 @@
Assert.AreSame(calculationGroup, groupContext.WrappedData);
Assert.AreSame(surfaceLines, groupContext.AvailablePipingSurfaceLines);
Assert.AreSame(soilModels, groupContext.AvailableStochasticSoilModels);
- Assert.AreSame(pipingFailureMechanismMock, groupContext.PipingFailureMechanism);
+ Assert.AreSame(pipingFailureMechanismMock, groupContext.FailureMechanism);
Assert.AreSame(assessmentSection, groupContext.AssessmentSection);
}
[Test]
- public void ParameteredConstructor_PipingFailureMechanismIsNull_ThrowArgumentNullException()
- {
- // Setup
- var group = new CalculationGroup();
- var surfaceLines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var soilModels = new[]
- {
- new TestStochasticSoilModel()
- };
-
- var mocks = new MockRepository();
- var assessmentSectionMock = mocks.StrictMock();
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new PipingCalculationGroupContext(group, surfaceLines, soilModels, null, assessmentSectionMock);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het piping faalmechanisme mag niet 'null' zijn.");
-
- mocks.VerifyAll();
- }
-
- [Test]
- public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
- {
- // Setup
- var group = new CalculationGroup();
- var surfaceLines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var soilModels = new[]
- {
- new TestStochasticSoilModel()
- };
-
- var mocks = new MockRepository();
- var pipingFailureMechanismMock = mocks.StrictMock();
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new PipingCalculationGroupContext(group, surfaceLines, soilModels, pipingFailureMechanismMock, null);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn.");
-
- mocks.VerifyAll();
- }
-
- [Test]
public void Attach_Observer_ObserverAttachedToCalculationGroup()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs (.../PipingCalculationScenarioContextTest.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingCalculationScenarioContextTest.cs (.../PipingCalculationScenarioContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -1,8 +1,5 @@
-using System;
-using Core.Common.Base;
-using Core.Common.TestUtil;
+using Core.Common.Base;
using NUnit.Framework;
-
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Piping.Data;
@@ -43,59 +40,11 @@
Assert.AreSame(calculation, presentationObject.WrappedData);
Assert.AreSame(surfacelines, presentationObject.AvailablePipingSurfaceLines);
Assert.AreSame(soilModels, presentationObject.AvailableStochasticSoilModels);
- Assert.AreSame(pipingFailureMechanismMock, presentationObject.PipingFailureMechanism);
+ Assert.AreSame(pipingFailureMechanismMock, presentationObject.FailureMechanism);
Assert.AreSame(assessmentSectionMock, presentationObject.AssessmentSection);
}
[Test]
- public void ParameteredConstructor_PipingFailureMechanismIsNull_ThrowArgumentNullException()
- {
- // Setup
- var surfacelines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var soilModels = new[]
- {
- new TestStochasticSoilModel()
- };
- var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
- var mocks = new MockRepository();
- var assessmentSection = mocks.StrictMock();
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new PipingCalculationScenarioContext(calculation, surfacelines, soilModels, null, assessmentSection);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het piping faalmechanisme mag niet 'null' zijn.");
- }
-
- [Test]
- public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
- {
- // Setup
- var surfacelines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var soilModels = new[]
- {
- new TestStochasticSoilModel()
- };
- var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
- var mocks = new MockRepository();
- var pipingFailureMechanismMock = mocks.StrictMock();
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new PipingCalculationScenarioContext(calculation, surfacelines, soilModels, pipingFailureMechanismMock, null);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn.");
- }
-
- [Test]
public void Attach_Observer_ObserverAttachedToPipingCalculation()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs
===================================================================
diff -u -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -42,6 +42,7 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
RingtoetsPipingSurfaceLine[] surfaceLines =
@@ -58,7 +59,7 @@
var target = new ObservableObject();
// Call
- var context = new SimplePipingContext(target, surfaceLines, soilModels, assessmentSection);
+ var context = new SimplePipingContext(target, surfaceLines, soilModels, pipingFailureMechanism, assessmentSection);
// Assert
Assert.IsInstanceOf(context);
@@ -67,6 +68,8 @@
Assert.AreSame(soilModels, context.AvailableStochasticSoilModels,
"It is vital that the iterator should be identical to the collection, in order to stay in sync when items are added or removed.");
Assert.AreSame(target, context.WrappedData);
+ Assert.AreSame(pipingFailureMechanism, context.FailureMechanism);
+ Assert.AreSame(assessmentSection, context.AssessmentSection);
mocks.VerifyAll();
}
@@ -77,12 +80,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
// Call
TestDelegate call = () => new SimplePipingContext(null,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
// Assert
@@ -101,12 +106,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
// Call
TestDelegate call = () => new SimplePipingContext(new ObservableObject(),
null,
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
// Assert
@@ -125,12 +132,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
// Call
TestDelegate call = () => new SimplePipingContext(new ObservableObject(),
Enumerable.Empty(),
null,
+ pipingFailureMechanism,
assessmentSection);
// Assert
@@ -144,11 +153,62 @@
}
[Test]
+ public void ParameteredConstructor_PipingFailureMechanismIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new SimplePipingContext(new ObservableObject(),
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ null,
+ assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ string customMessage = exception.Message.Split(new[]
+ {
+ Environment.NewLine
+ }, StringSplitOptions.None)[0];
+ Assert.AreEqual("Het piping faalmechanisme mag niet 'null' zijn.", customMessage);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var pipingFailureMechanism = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new SimplePipingContext(new ObservableObject(),
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanism,
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ string customMessage = exception.Message.Split(new[]
+ {
+ Environment.NewLine
+ }, StringSplitOptions.None)[0];
+ Assert.AreEqual("Het traject mag niet 'null' zijn.", customMessage);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Attach_Observer_ObserverAttachedToWrappedObject()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
@@ -158,6 +218,7 @@
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -174,6 +235,7 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
var observer = mocks.StrictMock();
mocks.ReplayAll();
@@ -182,6 +244,7 @@
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
context.Attach(observer);
@@ -200,6 +263,7 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
@@ -209,6 +273,7 @@
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
observableObject.Attach(observer); // Attach to wrapped object
@@ -226,12 +291,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -248,12 +315,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -270,12 +339,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
var otherContext = new SimplePipingContext(observableObject,
@@ -287,6 +358,7 @@
{
new StochasticSoilModel(0, string.Empty, string.Empty)
},
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -305,13 +377,15 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var otherObservableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
var otherContext = new SimplePipingContext(otherObservableObject,
@@ -323,6 +397,7 @@
{
new StochasticSoilModel(0, string.Empty, string.Empty)
},
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -341,13 +416,15 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
var observableStub = mocks.Stub();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
var otherContext = new SimplePipingContext(observableStub,
@@ -359,6 +436,7 @@
{
new StochasticSoilModel(0, string.Empty, string.Empty)
},
+ pipingFailureMechanism,
assessmentSection);
// Call
@@ -377,12 +455,14 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.StrictMock();
+ var pipingFailureMechanism = mocks.StrictMock();
mocks.ReplayAll();
var observableObject = new ObservableObject();
var context = new SimplePipingContext(observableObject,
Enumerable.Empty(),
Enumerable.Empty(),
+ pipingFailureMechanism,
assessmentSection);
var otherContext = new SimplePipingContext(observableObject,
@@ -394,6 +474,7 @@
{
new StochasticSoilModel(0, string.Empty, string.Empty)
},
+ pipingFailureMechanism,
assessmentSection);
// Precondition
Assert.True(context.Equals(otherContext));
@@ -409,8 +490,8 @@
private class SimplePipingContext : PipingContext where T : IObservable
{
- public SimplePipingContext(T target, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, IAssessmentSection assessmentSection)
- : base(target, surfaceLines, stochasticSoilModels, assessmentSection) {}
+ public SimplePipingContext(T target, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, PipingFailureMechanism pipingFailureMechanism, IAssessmentSection assessmentSection)
+ : base(target, surfaceLines, stochasticSoilModels, pipingFailureMechanism, assessmentSection) {}
}
private class ObservableObject : Observable {}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs
===================================================================
diff -u -rec5eeafbbd987b02a9d9c07b7e920c03d567f3f7 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs (.../PipingInputContextTest.cs) (revision ec5eeafbbd987b02a9d9c07b7e920c03d567f3f7)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingInputContextTest.cs (.../PipingInputContextTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -63,7 +63,7 @@
Assert.IsInstanceOf>(context);
Assert.AreSame(calculation.InputParameters, context.WrappedData);
Assert.AreSame(calculation, context.PipingCalculation);
- Assert.AreSame(failureMechanism, context.PipingFailureMechanism);
+ Assert.AreSame(failureMechanism, context.FailureMechanism);
Assert.AreSame(assessmentSection, context.AssessmentSection);
CollectionAssert.AreEqual(surfaceLines, context.AvailablePipingSurfaceLines);
CollectionAssert.AreEqual(stochasticSoilModels, context.AvailableStochasticSoilModels);
@@ -72,28 +72,6 @@
}
[Test]
- public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException()
- {
- // Setup
- var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
- var surfaceLines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var stochasticSoilModels = new[]
- {
- new TestStochasticSoilModel()
- };
- var failureMechanism = new PipingFailureMechanism();
-
- // Call
- TestDelegate call = () => new PipingInputContext(calculation.InputParameters, calculation, surfaceLines, stochasticSoilModels, failureMechanism, null);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn.");
- }
-
- [Test]
public void ParameteredConstructor_CalculationItemNull_ThrowsArgumentNullException()
{
// Setup
@@ -122,33 +100,6 @@
}
[Test]
- public void ParameteredConstructor_FailureMechanismNull_ThrowsArgumentNullException()
- {
- // Setup
- var calculation = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput());
- var surfaceLines = new[]
- {
- new RingtoetsPipingSurfaceLine()
- };
- var stochasticSoilModels = new[]
- {
- new TestStochasticSoilModel()
- };
-
- var mocks = new MockRepository();
- var assessmentSection = mocks.StrictMock();
-
- mocks.ReplayAll();
-
- // Call
- TestDelegate call = () => new PipingInputContext(calculation.InputParameters, calculation, surfaceLines, stochasticSoilModels, null, assessmentSection);
-
- // Assert
- TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het piping faalmechanisme mag niet 'null' zijn.");
- mocks.VerifyAll();
- }
-
- [Test]
public void Attach_Observer_ObserverAttachedToPipingInput()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -197,10 +197,10 @@
Assert.AreSame(calculationItem, children[0]);
var returnedCalculationContext = (PipingCalculationScenarioContext) children[1];
Assert.AreSame(childCalculation, returnedCalculationContext.WrappedData);
- Assert.AreSame(pipingFailureMechanismMock, returnedCalculationContext.PipingFailureMechanism);
+ Assert.AreSame(pipingFailureMechanismMock, returnedCalculationContext.FailureMechanism);
var returnedCalculationGroupContext = (PipingCalculationGroupContext) children[2];
Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData);
- Assert.AreSame(pipingFailureMechanismMock, returnedCalculationGroupContext.PipingFailureMechanism);
+ Assert.AreSame(pipingFailureMechanismMock, returnedCalculationGroupContext.FailureMechanism);
Assert.AreSame(assessmentSectionMock, returnedCalculationGroupContext.AssessmentSection);
mocks.VerifyAll();
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs
===================================================================
diff -u -r3b29807e8903b2cea3ee7a00a59b2b50f9de1f12 -rb1a215180352084c8f320439c1893c639917f338
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision 3b29807e8903b2cea3ee7a00a59b2b50f9de1f12)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision b1a215180352084c8f320439c1893c639917f338)
@@ -166,7 +166,7 @@
CollectionAssert.AreEqual(pipingFailureMechanism.CalculationsGroup.Children, calculationsFolder.WrappedData.Children);
Assert.AreSame(pipingFailureMechanism.SurfaceLines, calculationsFolder.AvailablePipingSurfaceLines);
Assert.AreEqual(pipingFailureMechanism.StochasticSoilModels, calculationsFolder.AvailableStochasticSoilModels);
- Assert.AreSame(pipingFailureMechanism, calculationsFolder.PipingFailureMechanism);
+ Assert.AreSame(pipingFailureMechanism, calculationsFolder.FailureMechanism);
var outputsFolder = (CategoryTreeFolder) children[2];
Assert.AreEqual("Uitvoer", outputsFolder.Name);