Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs =================================================================== diff -u -rf0c2ddbf7c66e63f843811d2a8687f9679c4043b -r40384a737099f1ed7e6665d88165782d40951d6d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision f0c2ddbf7c66e63f843811d2a8687f9679c4043b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/CalculationTreeNodeInfoFactoryTest.cs (.../CalculationTreeNodeInfoFactoryTest.cs) (revision 40384a737099f1ed7e6665d88165782d40951d6d) @@ -230,9 +230,9 @@ [Test] [Combinatorial] - public void CanDropOrCanInsertOfCalculationGroupContextTreeNodeInfo_DraggingPipingCalculationItemContextOntoGroupNotContainingItem_ReturnsTrue( + public void CanDropOrCanInsertOfCalculationGroupContextTreeNodeInfo_DraggingCalculationItemContextOntoGroupNotContainingItem_ReturnsTrue( [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, - [Values(CalculationType.Calculation, CalculationType.Group)] CalculationType draggedItemType) + [Values(CalculationItemType.Calculation, CalculationItemType.Group)] CalculationItemType draggedItemType) { // Setup var mocks = new MockRepository(); @@ -242,7 +242,7 @@ object draggedItemContext; ICalculationBase draggedItem; - CreateCalculationAndContext(draggedItemType, out draggedItem, out draggedItemContext, failureMechanism); + CreateCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, failureMechanism); CalculationGroup targetGroup; TestCalculationGroupContext targetGroupContext; @@ -277,7 +277,7 @@ [Combinatorial] public void CanDropOrInsertOfCalculationGroupContextTreeNodeInfo_DraggingCalculationItemContextOntoGroupNotContainingItemOtherFailureMechanism_ReturnsFalse( [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, - [Values(CalculationType.Calculation, CalculationType.Group)] CalculationType draggedItemType) + [Values(CalculationItemType.Calculation, CalculationItemType.Group)] CalculationItemType draggedItemType) { // Setup var mocks = new MockRepository(); @@ -288,7 +288,7 @@ object draggedItemContext; ICalculationBase draggedItem; - CreateCalculationAndContext(draggedItemType, out draggedItem, out draggedItemContext, targetFailureMechanism); + CreateCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, targetFailureMechanism); CalculationGroup targetGroup; TestCalculationGroupContext targetGroupContext; @@ -319,6 +319,56 @@ mocks.VerifyAll(); } + /// + /// Creates an instance of and the corresponding . + /// + /// The created group without any children. + /// The context object for , without any other data. + /// The failure mechanism the item and context it belong to. + private void CreateCalculationGroupAndContext(out CalculationGroup data, out TestCalculationGroupContext dataContext, IFailureMechanism failureMechanism) + { + data = new CalculationGroup(); + dataContext = new TestCalculationGroupContext(data, failureMechanism); + } + + /// + /// Creates an instance of and the corresponding context. + /// + /// Defines the implementation of to be constructed. + /// Output: The concrete create class based on . + /// Output: The context corresponding with . + /// The failure mechanism the item and context belong to. + /// Optional: The name of . + /// + private static void CreateCalculationItemAndContext(CalculationItemType type, out ICalculationBase data, out object dataContext, IFailureMechanism failureMechanism, string initialName = null) + { + switch (type) + { + case CalculationItemType.Calculation: + var calculation = new TestCalculation(); + if (initialName != null) + { + calculation.Name = initialName; + } + data = calculation; + dataContext = new TestCalculationContext(calculation, failureMechanism); + break; + case CalculationItemType.Group: + var group = new CalculationGroup(); + if (initialName != null) + { + group.Name = initialName; + } + data = group; + dataContext = new TestCalculationGroupContext(group, failureMechanism); + break; + default: + throw new NotSupportedException(); + } + } + + # region Nested types + private class TestCalculationGroupContext : Observable, ICalculationContext { public TestCalculationGroupContext(CalculationGroup wrappedData, IFailureMechanism failureMechanism) @@ -376,54 +426,6 @@ } /// - /// Creates an instance of and the corresponding . - /// - /// The created group without any children. - /// The context object for , without any other data. - /// The failure mechanism the item and context it belong to. - private void CreateCalculationGroupAndContext(out CalculationGroup data, out TestCalculationGroupContext dataContext, IFailureMechanism failureMechanism) - { - data = new CalculationGroup(); - dataContext = new TestCalculationGroupContext(data, failureMechanism); - } - - /// - /// Creates an instance of and the corresponding context. - /// - /// Defines the implementation of to be constructed. - /// Output: The concrete create class based on . - /// Output: The context corresponding with . - /// The failure mechanism the item and context belong to. - /// Optional: The name of . - /// - private static void CreateCalculationAndContext(CalculationType type, out ICalculationBase data, out object dataContext, IFailureMechanism failureMechanism, string initialName = null) - { - switch (type) - { - case CalculationType.Calculation: - var calculation = new TestCalculation(); - if (initialName != null) - { - calculation.Name = initialName; - } - data = calculation; - dataContext = new TestCalculationContext(calculation, failureMechanism); - break; - case CalculationType.Group: - var group = new CalculationGroup(); - if (initialName != null) - { - group.Name = initialName; - } - data = group; - dataContext = new TestCalculationGroupContext(group, failureMechanism); - break; - default: - throw new NotSupportedException(); - } - } - - /// /// Type indicator for testing methods on . /// public enum DragDropTestMethod @@ -442,7 +444,7 @@ /// /// Type indicator for implementations of to be created in a test. /// - public enum CalculationType + public enum CalculationItemType { /// /// Indicates . @@ -454,5 +456,7 @@ /// Group } + + # endregion } } \ No newline at end of file