Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs =================================================================== diff -u -rd8ca552454f8c1bf36269890b70f104c810fbf7f -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs (.../ProjectTreeNodeInfoTest.cs) (revision d8ca552454f8c1bf36269890b70f104c810fbf7f) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs (.../ProjectTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -143,7 +143,7 @@ [Test] [RequiresSTA] - public void GetContextMenu_Always_AddsAddItem() + public void ContextMenuStrip_Always_AddsAddItem() { // Setup var project = new Project(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs =================================================================== diff -u -r39ad631dab6b2ae544ccdabf22fad6b4e5493218 -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision 39ad631dab6b2ae544ccdabf22fad6b4e5493218) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -226,8 +226,8 @@ } } - public class TestAssessmentSectionBase : AssessmentSectionBase { - + public class TestAssessmentSectionBase : AssessmentSectionBase + { private readonly IEnumerable failureMechanisms; public TestAssessmentSectionBase(FailureMechanismContribution contribution, IEnumerable failureMechanisms) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs =================================================================== diff -u -rd8ca552454f8c1bf36269890b70f104c810fbf7f -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs (.../FailureMechanismContributionTreeNodeInfoTest.cs) (revision d8ca552454f8c1bf36269890b70f104c810fbf7f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs (.../FailureMechanismContributionTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -70,7 +70,6 @@ mocks.VerifyAll(); } - [Test] public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs =================================================================== diff -u -rd8ca552454f8c1bf36269890b70f104c810fbf7f -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs (.../PlaceholderWithReadonlyNameTreeNodeInfoTest.cs) (revision d8ca552454f8c1bf36269890b70f104c810fbf7f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs (.../PlaceholderWithReadonlyNameTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -102,7 +102,7 @@ } [Test] - public void GetContextMenu_OutputPlaceHolder_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_OutputPlaceHolder_CallsContextMenuBuilderMethods() { // Setup var outputPlaceholder = new OutputPlaceholder(string.Empty); @@ -133,7 +133,7 @@ } [Test] - public void GetContextMenu_InputPlaceHolder_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_InputPlaceHolder_CallsContextMenuBuilderMethods() { // Setup var inputPlaceholder = new InputPlaceholder(string.Empty); @@ -163,7 +163,7 @@ } [Test] - public void GetContextMenu_PlaceHolder_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_PlaceHolder_CallsContextMenuBuilderMethods() { // Setup var gui = mocks.StrictMock(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r95487d39e17289b2a656e34d85b808186222c0ee -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 95487d39e17289b2a656e34d85b808186222c0ee) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -291,9 +291,9 @@ /// /// Looks up a localized string similar to Weet u zeker dat u de uitvoer van deze berekening wilt wissen?. /// - public static string PipingCalculationContext_GetContextMenu_Are_you_sure_clear_output { + public static string PipingCalculationContext_ContextMenuStrip_Are_you_sure_clear_output { get { - return ResourceManager.GetString("PipingCalculationContext_GetContextMenu_Are_you_sure_clear_output", resourceCulture); + return ResourceManager.GetString("PipingCalculationContext_ContextMenuStrip_Are_you_sure_clear_output", resourceCulture); } } @@ -399,9 +399,9 @@ /// /// Looks up a localized string similar to Weet u zeker dat u alle uitvoer wilt wissen?. /// - public static string PipingCalculationGroupContext_GetContextMenu_Are_you_sure_clear_all_output { + public static string PipingCalculationGroupContext_ContextMenuStrip_Are_you_sure_clear_all_output { get { - return ResourceManager.GetString("PipingCalculationGroupContext_GetContextMenu_Are_you_sure_clear_all_output", resourceCulture); + return ResourceManager.GetString("PipingCalculationGroupContext_ContextMenuStrip_Are_you_sure_clear_all_output", resourceCulture); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx =================================================================== diff -u -r95487d39e17289b2a656e34d85b808186222c0ee -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision 95487d39e17289b2a656e34d85b808186222c0ee) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -517,13 +517,13 @@ Wis de uitvoer van alle berekeningen binnen deze berekeningsmap. - + Weet u zeker dat u alle uitvoer wilt wissen? Valideer alle berekeningen binnen deze berekeningsmap. - + Weet u zeker dat u de uitvoer van deze berekening wilt wissen? Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -rd03f2b52982110a0f804adfefe73f86551c59e62 -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision d03f2b52982110a0f804adfefe73f86551c59e62) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -292,7 +292,7 @@ private static void ClearAll(PipingFailureMechanism failureMechanism) { - if (MessageBox.Show(PipingFormsResources.PipingCalculationGroupContext_GetContextMenu_Are_you_sure_clear_all_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) + if (MessageBox.Show(PipingFormsResources.PipingCalculationGroupContext_ContextMenuStrip_Are_you_sure_clear_all_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } @@ -471,7 +471,7 @@ private static void ClearOutput(PipingCalculation calculation) { - if (MessageBox.Show(PipingFormsResources.PipingCalculationContext_GetContextMenu_Are_you_sure_clear_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) + if (MessageBox.Show(PipingFormsResources.PipingCalculationContext_ContextMenuStrip_Are_you_sure_clear_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } @@ -556,7 +556,7 @@ PipingFormsResources.PipingCalculationGroup_ClearOutput_ToolTip, RingtoetsFormsResources.ClearIcon, (o, args) => { - if (MessageBox.Show(PipingFormsResources.PipingCalculationGroupContext_GetContextMenu_Are_you_sure_clear_all_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) + if (MessageBox.Show(PipingFormsResources.PipingCalculationGroupContext_ContextMenuStrip_Are_you_sure_clear_all_output, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs =================================================================== diff -u -rd8ca552454f8c1bf36269890b70f104c810fbf7f -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs (.../EmptyPipingCalculationReportTreeNodeInfoTest.cs) (revision d8ca552454f8c1bf36269890b70f104c810fbf7f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs (.../EmptyPipingCalculationReportTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -80,7 +80,7 @@ } [Test] - public void GetContextMenu_Always_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var gui = mocks.StrictMock(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs =================================================================== diff -u -rd8ca552454f8c1bf36269890b70f104c810fbf7f -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs (.../EmptyPipingOutputTreeNodeInfoTest.cs) (revision d8ca552454f8c1bf36269890b70f104c810fbf7f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs (.../EmptyPipingOutputTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -78,7 +78,7 @@ } [Test] - public void GetContextMenu_Always_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var gui = mocks.StrictMock(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -ra1de055e3698f610875e623d39f4526970568cef -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision a1de055e3698f610875e623d39f4526970568cef) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -123,7 +123,7 @@ } [Test] - public void GetChildNodeObjects_WithOutputData_ReturnOutputChildNode() + public void ChildNodeObjects_WithOutputData_ReturnOutputChildNode() { // Setup var calculation = new PipingCalculation @@ -160,7 +160,7 @@ } [Test] - public void GetChildNodeObjects_WithoutOutput_ReturnNoChildNodes() + public void ChildNodeObjects_WithoutOutput_ReturnNoChildNodes() { // Setup var pipingFailureMechanismMock = mocks.StrictMock(); @@ -240,7 +240,7 @@ } [Test] - public void GetContextMenu_PipingCalculationWithoutOutput_ContextMenuItemClearOutputDisabled() + public void ContextMenuStrip_PipingCalculationWithoutOutput_ContextMenuItemClearOutputDisabled() { var gui = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); @@ -269,7 +269,7 @@ } [Test] - public void GetContextMenu_PipingCalculationWithOutput_ContextMenuItemClearOutputEnabled() + public void ContextMenuStrip_PipingCalculationWithOutput_ContextMenuItemClearOutputEnabled() { var gui = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); @@ -301,7 +301,7 @@ } [Test] - public void GetContextMenu_Always_CallsContextMenuBuilderMethods() + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var gui = mocks.StrictMock(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rd03f2b52982110a0f804adfefe73f86551c59e62 -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision d03f2b52982110a0f804adfefe73f86551c59e62) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -50,55 +50,42 @@ } [Test] - public void EnsureVisibleOnCreate_Always_ReturnsTrue() + public void Text_Always_ReturnsWrappedDataName() { // Setup - var group = new PipingCalculationGroup(); + var testname = "testName"; + var group = new PipingCalculationGroup { Name = testname }; var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); var groupContext = new PipingCalculationGroupContext(group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); - mocks.ReplayAll(); - // Call - var result = info.EnsureVisibleOnCreate(groupContext); + var text = info.Text(groupContext); // Assert - Assert.IsTrue(result); - - mocks.VerifyAll(); + Assert.AreEqual(testname, text); } [Test] - public void CanDrag_WithParentNodeDefaultBehavior_ReturnTrue() + public void Image_Always_FolderIcon() { - // Setup - var group = new PipingCalculationGroup(); - var pipingFailureMechanismMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var groupContext = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - // Call - var canDrag = info.CanDrag(groupContext, null); + var image = info.Image(null); // Assert - Assert.IsTrue(canDrag); + TestHelper.AssertImagesAreEqual(PipingFormsResources.FolderIcon, image); } [Test] - public void CanDrag_ParentIsPipingFailureMechanism_ReturnFalse() + public void EnsureVisibleOnCreate_Always_ReturnsTrue() { // Setup - var pipingFailureMechanism = new PipingFailureMechanism(); - var group = pipingFailureMechanism.CalculationsGroup; + var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); mocks.ReplayAll(); @@ -107,585 +94,87 @@ Enumerable.Empty(), pipingFailureMechanismMock); - // Call - var canDrag = info.CanDrag(groupContext, pipingFailureMechanism); - - // Assert - Assert.IsFalse(canDrag); - } - - [Test] - [Combinatorial] - public void CanDropOrCanInsert_DraggingPipingCalculationItemContextOntoGroupNotContainingItem_ReturnMoveOrTrue( - [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, - [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) - { - // Setup - IPipingCalculationItem draggedItem; - object draggedItemContext; - - var failureMechanism = new PipingFailureMechanism(); - - CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, failureMechanism); - - PipingCalculationGroup targetGroup; - PipingCalculationGroupContext targetGroupContext; - CreatePipingCalculationGroupAndContext(out targetGroup, out targetGroupContext, failureMechanism); - - failureMechanism.CalculationsGroup.Children.Add(draggedItem); - failureMechanism.CalculationsGroup.Children.Add(targetGroup); - - switch (methodToTest) - { - case DragDropTestMethod.CanDrop: - // Call - var canDrop = info.CanDrop(draggedItemContext, targetGroupContext); - - // Assert - Assert.IsTrue(canDrop); - break; - case DragDropTestMethod.CanInsert: - // Call - bool canInsert = info.CanInsert(draggedItemContext, targetGroupContext); - - // Assert - Assert.IsTrue(canInsert); - break; - default: - Assert.Fail(methodToTest + " not supported."); - break; - } - mocks.VerifyAll(); - } - - [Test] - [Combinatorial] - public void CanDropOrInsert_DraggingCalculationItemContextOntoGroupNotContainingItemOtherFailureMechanism_ReturnNoneOrFalse( - [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, - [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) - { - // Setup - IPipingCalculationItem draggedItem; - object draggedItemContext; - - var targetFailureMechanism = new PipingFailureMechanism(); - - CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, targetFailureMechanism); - - var sourceFailureMechanism = new PipingFailureMechanism(); - sourceFailureMechanism.CalculationsGroup.Children.Add(draggedItem); - - PipingCalculationGroup targetGroup; - PipingCalculationGroupContext targetGroupContext; - CreatePipingCalculationGroupAndContext(out targetGroup, out targetGroupContext, sourceFailureMechanism); - - targetFailureMechanism.CalculationsGroup.Children.Add(targetGroup); - - switch (methodToTest) - { - case DragDropTestMethod.CanDrop: - // Call - var canDrop = info.CanDrop(draggedItemContext, targetGroupContext); - - // Assert - Assert.IsFalse(canDrop); - break; - case DragDropTestMethod.CanInsert: - // Call - bool canInsert = info.CanInsert(draggedItemContext, targetGroupContext); - - // Assert - Assert.IsFalse(canInsert); - break; - default: - Assert.Fail(methodToTest + " not supported."); - break; - } - mocks.VerifyAll(); - } - -// [Test] -// [Combinatorial] -// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupEnd_MoveCalculationItemInstanceToNewGroup( -// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) -// { -// // Setup -// IPipingCalculationItem draggedItem; -// object draggedItemContext; -// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); -// -// PipingCalculationGroup originalOwnerGroup; -// PipingCalculationGroupContext originalOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); -// originalOwnerGroup.Children.Add(draggedItem); -// -// PipingCalculationGroup newOwnerGroup; -// PipingCalculationGroupContext newOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); -// -// var originalOwnerObserver = mocks.StrictMock(); -// originalOwnerObserver.Expect(o => o.UpdateObserver()); -// -// var updatewasCalled = false; -// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updatewasCalled = true); -// -// var newOwnerGroupContextNode = new TreeNode -// { -// Tag = newOwnerGroupContext -// }; -// -// var originalOwnerGroupContextNode = new TreeNode -// { -// Tag = originalOwnerGroupContext -// }; -// -// var draggedItemContextNode = new TreeNode -// { -// Tag = draggedItemContext -// }; -// draggedItemContextNode.Collapse(); -// -// newOwnerGroupContextNode.Nodes.Add(draggedItemContextNode); -// -// mocks.ReplayAll(); -// -// var treeView = new Core.Common.Controls.TreeView.TreeView(); -// var root = new TreeNode(); -// treeView.Nodes.Add(root); -// root.Nodes.Add(originalOwnerGroupContextNode); -// root.Nodes.Add(newOwnerGroupContextNode); -// -// originalOwnerGroup.Attach(originalOwnerObserver); -// newOwnerGroup.Attach(newOwnerObserver); -// -// // Precondition: -// Assert.IsFalse(draggedItemContextNode.IsExpanded); -// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); -// -// // Call -// info.OnDrop(draggedItemContextNode, newOwnerGroupContextNode, newOwnerGroup.Children.Count); -// -// // Assert -// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); -// Assert.AreSame(draggedItem, newOwnerGroup.Children.Last(), -// "Dragging node at the end of the target PipingCalculationGroup should put the dragged data at the end of 'newOwnerGroup'."); -// -// Assert.AreSame(draggedItemContextNode, draggedItemContextNode.TreeView.SelectedNode); -// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); -// Assert.IsFalse(draggedItemContextNode.IsExpanded); -// -// mocks.VerifyAll(); -// } -// -// [Test] -// [Combinatorial] -// public void OnDragDrop_InsertingPipingCalculationItemContextAtDifferentLocationWithingSameGroup_ChangeItemIndexOfCalculationItem( -// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType, -// [Values(0, 2)] int newIndex) -// { -// // Setup -// const string name = "Very cool name"; -// IPipingCalculationItem draggedItem; -// object draggedItemContext; -// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, name); -// -// var existingItemStub = mocks.Stub(); -// existingItemStub.Stub(i => i.Name).Return(""); -// -// PipingCalculationGroup originalOwnerGroup; -// PipingCalculationGroupContext originalOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); -// originalOwnerGroup.Children.Add(existingItemStub); -// originalOwnerGroup.Children.Add(draggedItem); -// originalOwnerGroup.Children.Add(existingItemStub); -// -// bool updatewasCalled = false; -// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updatewasCalled = true); -// -// var existingItemStub1 = CreateStubTreeNode(); -// var existingItemStub2 = CreateStubTreeNode(); -// -// var preUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); -// var postUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); -// TreeNode[] preUpdateNewOwnerChildNodes = { existingItemStub1, preUpdateDraggedItemContextNode, existingItemStub2 }; -// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(originalOwnerGroupContext, preUpdateNewOwnerChildNodes, invocation => -// { -// if (updatewasCalled) -// { -// invocation.ReturnValue = new[] -// { -// existingItemStub1, -// postUpdateDraggedItemContextNode, -// existingItemStub2 -// }; -// } -// }); -// postUpdateDraggedItemContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); -// -// mocks.ReplayAll(); -// -// originalOwnerGroup.Attach(originalOwnerObserver); -// -// // Precondition: -// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); -// -// // Call -// info.OnDrop(preUpdateDraggedItemContextNode, newOwnerGroupContextNode, newIndex); -// -// // Assert -// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); -// Assert.AreNotSame(draggedItem, originalOwnerGroup.Children[1], -// "Should have removed 'draggedItem' from its original location in the collection."); -// Assert.AreSame(draggedItem, originalOwnerGroup.Children[newIndex], -// "Dragging node to specific location within owning PipingCalculationGroup should put the dragged data at that index."); -// Assert.AreEqual(name, draggedItem.Name, -// "No renaming should occur when dragging within the same PipingCalculationGroup."); -// -// Assert.AreSame(postUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode.TreeView.SelectedNode); -// -// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); -// -// mocks.VerifyAll(); -// } -// -// [Test] -// [Combinatorial] -// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupStartWithSameNamedItem_MoveCalculationItemInstanceToNewGroupAndRename( -// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) -// { -// // Setup -// IPipingCalculationItem draggedItem; -// object draggedItemContext; -// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); -// -// PipingCalculationGroup originalOwnerGroup; -// PipingCalculationGroupContext originalOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); -// originalOwnerGroup.Children.Add(draggedItem); -// -// PipingCalculationGroup newOwnerGroup; -// PipingCalculationGroupContext newOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); -// -// var sameNamedItem = mocks.Stub(); -// sameNamedItem.Stub(i => i.Name).Return(draggedItem.Name); -// -// var updateWasCalled = false; -// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(); -// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updateWasCalled = true); -// -// var preUpdateCalculationContextNode = CreateExpandedNodeStub(draggedItemContext, new TreeNode[0]); -// var postUpdateCalculationContextNode = CreateNodeStubToBeExpanded(draggedItemContext, new TreeNode[0]); -// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(originalOwnerGroupContext, new TreeNode[0], invocation => -// { -// if (updateWasCalled) -// { -// invocation.ReturnValue = new[] -// { -// postUpdateCalculationContextNode -// }; -// } -// }); -// postUpdateCalculationContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); -// -// mocks.ReplayAll(); -// -// newOwnerGroup.Children.Add(sameNamedItem); -// -// originalOwnerGroup.Attach(originalOwnerObserver); -// newOwnerGroup.Attach(newOwnerObserver); -// -// // Precondition: -// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); -// CollectionAssert.Contains(newOwnerGroup.Children.Select(c => c.Name), draggedItem.Name, -// "Name of the dragged item should already exist in new owner."); -// -// // Call -// info.OnDrop(preUpdateCalculationContextNode, newOwnerGroupContextNode, 0); -// -// // Assert -// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); -// Assert.AreSame(draggedItem, newOwnerGroup.Children.First(), -// "Dragging to insert node at start of newOwnerGroup should place the node at the start of the list."); -// switch (draggedItemType) -// { -// case PipingCalculationItemType.Calculation: -// Assert.AreEqual("Nieuwe berekening (1)", draggedItem.Name); -// break; -// case PipingCalculationItemType.Group: -// Assert.AreEqual("Nieuwe map (1)", draggedItem.Name); -// break; -// } -// -// Assert.AreSame(postUpdateCalculationContextNode, postUpdateCalculationContextNode.TreeView.SelectedNode); -// -// Assert.IsTrue(postUpdateCalculationContextNode.IsExpanded); -// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); -// -// mocks.VerifyAll(); -// } -// -// [Test] -// [Combinatorial] -// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupWithOtherItems_ExpandedCollapsedStateOfOtherItemsRestored( -// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) -// { -// // Setup -// IPipingCalculationItem draggedItem; -// object draggedItemContext; -// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); -// -// PipingCalculationGroup originalOwnerGroup; -// PipingCalculationGroupContext originalOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); -// originalOwnerGroup.Children.Add(draggedItem); -// -// PipingCalculationGroup newOwnerGroup; -// PipingCalculationGroupContext newOwnerGroupContext; -// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); -// -// var updatewasCalled = false; -// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(); -// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(methodInvocation => updatewasCalled = true); -// -// var nodeStub = CreateStubTreeNode(); -// TreeNode[] childNodesStub = { nodeStub }; -// -// var expandedNodeData = new object(); -// var preUpdateExpandedNode = CreateExpandedNodeStub(expandedNodeData, childNodesStub); -// var postUpdateExpandedNode = CreateNodeStubToBeExpanded(expandedNodeData, childNodesStub); -// -// var collapsedNodeData = new object(); -// var preUpdateCollapsedNode = CreateCollapsedNodeStub(collapsedNodeData, childNodesStub); -// var postUpdateCollapsedNode = CreateNodeStubToBeCollapsed(collapsedNodeData, childNodesStub); -// -// TreeNode[] preUpdateChildNodes = { preUpdateExpandedNode, preUpdateCollapsedNode }; -// TreeNode[] postUpdateChildNodes = { postUpdateExpandedNode, postUpdateCollapsedNode }; -// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(newOwnerGroupContext, preUpdateChildNodes, invocation => -// { -// if (updatewasCalled) -// { -// invocation.ReturnValue = postUpdateChildNodes; -// } -// }); -// -// var preUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); -// var postUpdateDraggedItemContextNode = CreateNodeStubToBeCollapsed(draggedItemContext, new TreeNode[0]); -// postUpdateDraggedItemContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); -// -// mocks.ReplayAll(); -// -// originalOwnerGroup.Attach(originalOwnerObserver); -// newOwnerGroup.Attach(newOwnerObserver); -// -// // Precondition: -// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); -// -// // Call -// info.OnDrop(preUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode, newOwnerGroup.Children.Count); -// -// // Assert -// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); -// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); -// Assert.AreSame(draggedItem, newOwnerGroup.Children.Last(), -// "Dragging node at the end of the target PipingCalculationGroup should put the dragged data at the end of 'newOwnerGroup'."); -// -// Assert.AreSame(postUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode.TreeView.SelectedNode); -// Assert.IsFalse(postUpdateCollapsedNode.IsExpanded); -// Assert.IsFalse(postUpdateDraggedItemContextNode.IsExpanded); -// Assert.IsTrue(postUpdateExpandedNode.IsExpanded); -// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); -// -// mocks.VerifyAll(); -// } - - [Test] - public void CanRenameNode_ParentIsPipingFailureMechanismNode_ReturnFalse() - { - // Setup - var failureMechanism = new PipingFailureMechanism(); - mocks.ReplayAll(); // Call - bool isRenamingAllowed = info.CanRename(null, failureMechanism); + var result = info.EnsureVisibleOnCreate(groupContext); // Assert - Assert.IsFalse(isRenamingAllowed); - mocks.VerifyAll(); - } + Assert.IsTrue(result); - [Test] - public void CanRenameNode_EverythingElse_ReturnTrue() - { - // Call - bool isRenamingAllowed = info.CanRename(null, null); - - // Assert - Assert.IsTrue(isRenamingAllowed); mocks.VerifyAll(); } [Test] - public void OnNodeRenamed_WithData_RenameGroupAndNotifyObservers() + public void ChildNodeObjects_EmptyGroup_ReturnEmpty() { // Setup - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); mocks.ReplayAll(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - nodeData.Attach(observer); + var groupContext = new PipingCalculationGroupContext(@group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); // Call - const string newName = "new name"; - info.OnNodeRenamed(nodeData, newName); + var children = info.ChildNodeObjects(groupContext); // Assert - Assert.AreEqual(newName, group.Name); - mocks.VerifyAll(); + CollectionAssert.IsEmpty(children); } [Test] - public void CanRemove_ParentIsFailureMechanism_ReturnFalse() + public void ChildNodeObjects_GroupWithMixedContents_ReturnChildren() { // Setup - var group = new PipingCalculationGroup(); - var pipingFailureMechanismMock = mocks.StrictMock(); - mocks.ReplayAll(); + var calculationItem = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); + var childCalculation = new PipingCalculation(); - var parentNodeData = new PipingFailureMechanism(); - parentNodeData.CalculationsGroup.Children.Add(group); + var childGroup = new PipingCalculationGroup(); - mocks.ReplayAll(); - - // Call - bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); - - // Assert - Assert.IsFalse(isRemovalAllowed); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentIsPipingCalculationGroupContainingGroup_ReturnTrue() - { - // Setup var group = new PipingCalculationGroup(); - var pipingFailureMechanismMock = mocks.StrictMock(); - mocks.ReplayAll(); + @group.Children.Add(calculationItem); + @group.Children.Add(childCalculation); + @group.Children.Add(childGroup); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - - var parentGroup = new PipingCalculationGroup(); - parentGroup.Children.Add(group); - var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - - mocks.ReplayAll(); - - // Call - bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); - - // Assert - Assert.IsTrue(isRemovalAllowed); - mocks.VerifyAll(); - } - - [Test] - public void CanRemove_ParentIsPipingCalculationGroupNotContainingGroup_ReturnFalse() - { - // Setup - var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); - mocks.ReplayAll(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - - var parentGroup = new PipingCalculationGroup(); - var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - - // Precondition - CollectionAssert.DoesNotContain(parentGroup.Children, group); - - // Call - bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); - - // Assert - Assert.IsFalse(isRemovalAllowed); - } - - [Test] - public void CanRemove_ParentIsPipingCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers() - { - // Setup - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - var group = new PipingCalculationGroup(); - var pipingFailureMechanismMock = mocks.StrictMock(); mocks.ReplayAll(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); - var parentGroup = new PipingCalculationGroup(); - parentGroup.Children.Add(group); - var parentNodeData = new PipingCalculationGroupContext(parentGroup, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); - parentNodeData.Attach(observer); - - // Precondition - Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); - // Call - info.OnNodeRemoved(nodeData, parentNodeData); + var children = info.ChildNodeObjects(nodeData).ToArray(); // Assert - CollectionAssert.DoesNotContain(parentGroup.Children, group); + Assert.AreEqual(@group.Children.Count, children.Length); + Assert.AreSame(calculationItem, children[0]); + var returnedCalculationContext = (PipingCalculationContext) children[1]; + Assert.AreSame(childCalculation, returnedCalculationContext.WrappedData); + Assert.AreSame(pipingFailureMechanismMock, returnedCalculationContext.PipingFailureMechanism); + var returnedCalculationGroupContext = (PipingCalculationGroupContext)children[2]; + Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); + Assert.AreSame(pipingFailureMechanismMock, returnedCalculationGroupContext.PipingFailureMechanism); mocks.VerifyAll(); } [Test] - public void GetContextMenu_ChildOfGroupValidDataWithCalculationOutput_ReturnContextMenuWithAllItems() + public void ContextMenuStrip_ChildOfGroupValidDataWithCalculationOutput_ReturnContextMenuWithAllItems() { // Setup var gui = mocks.StrictMock(); var parentGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); - parentGroup.Children.Add(group); - group.Children.Add(new PipingCalculation + parentGroup.Children.Add(@group); + @group.Children.Add(new PipingCalculation { Output = new TestPipingOutput() }); @@ -697,7 +186,7 @@ Enumerable.Empty(), pipingFailureMechanismMock); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -794,21 +283,21 @@ } [Test] - public void GetContextMenu_NotValidDataWithCalculationOutput_ReturnContextWithItems() + public void ContextMenuStrip_NotValidDataWithCalculationOutput_ReturnContextWithItems() { // Setup var gui = mocks.StrictMock(); var group = new PipingCalculationGroup(); - group.Children.Add(new PipingCalculation + @group.Children.Add(new PipingCalculation { Output = new TestPipingOutput() }); var pipingFailureMechanismMock = mocks.StrictMock(); var parentData = new object(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -899,21 +388,21 @@ } [Test] - public void GetContextMenu_ParentWithFailureMechanism_ReturnContextMenuWithoutRenameRemove() + public void ContextMenuStrip_ParentWithFailureMechanism_ReturnContextMenuWithoutRenameRemove() { // Setup var gui = mocks.StrictMock(); var group = new PipingCalculationGroup(); - group.Children.Add(new PipingCalculation + @group.Children.Add(new PipingCalculation { Output = new TestPipingOutput() }); var pipingFailureMechanismMock = mocks.StrictMock(); var parentData = new PipingFailureMechanism(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -997,7 +486,7 @@ } [Test] - public void GetContextMenu_GroupWithNoCalculations_ValidateAndCalculateAllDisabled() + public void ContextMenuStrip_GroupWithNoCalculations_ValidateAndCalculateAllDisabled() { // Setup var gui = mocks.StrictMock(); @@ -1007,7 +496,7 @@ var group = new PipingCalculationGroup(); var parentData = new PipingFailureMechanism(); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1033,14 +522,14 @@ } [Test] - public void GetContextMenu_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() + public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup var gui = mocks.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1059,21 +548,21 @@ plugin.Gui = gui; - group.Children.Add(calculationItem); + @group.Children.Add(calculationItem); nodeData.Attach(observer); ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Precondition - Assert.AreEqual(1, group.Children.Count); + Assert.AreEqual(1, @group.Children.Count); // Call contextMenu.Items[contextMenuAddCalculationGroupIndex].PerformClick(); // Assert - Assert.AreEqual(2, group.Children.Count); - var newlyAddedItem = group.Children.Last(); + Assert.AreEqual(2, @group.Children.Count); + var newlyAddedItem = @group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); @@ -1082,14 +571,14 @@ } [Test] - public void GetContextMenu_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers() + public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers() { // Setup var gui = mocks.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1108,21 +597,21 @@ plugin.Gui = gui; - group.Children.Add(calculationItem); + @group.Children.Add(calculationItem); nodeData.Attach(observer); var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Precondition - Assert.AreEqual(1, group.Children.Count); + Assert.AreEqual(1, @group.Children.Count); // Call contextMenu.Items[contextMenuAddCalculationIndex].PerformClick(); // Assert - Assert.AreEqual(2, group.Children.Count); - var newlyAddedItem = group.Children.Last(); + Assert.AreEqual(2, @group.Children.Count); + var newlyAddedItem = @group.Children.Last(); Assert.IsInstanceOf(newlyAddedItem); Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); @@ -1131,7 +620,7 @@ } [Test] - public void GetContextMenu_ClickOnValidateAllItem_ValidateAllChildCalculations() + public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations() { // Setup var gui = mocks.StrictMock(); @@ -1149,13 +638,13 @@ var emptyChildGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(invalidCalculation); + @group.Children.Add(childGroup); + @group.Children.Add(emptyChildGroup); + @group.Children.Add(invalidCalculation); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1187,7 +676,7 @@ } [Test] - public void GetContextMenu_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() { // Setup var gui = mocks.StrictMock(); @@ -1206,13 +695,13 @@ var emptyChildGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(invalidCalculation); + @group.Children.Add(childGroup); + @group.Children.Add(emptyChildGroup); + @group.Children.Add(invalidCalculation); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1238,7 +727,7 @@ [Test] [TestCase(false)] [TestCase(true)] - public void GetContextMenu_ClickOnClearOutputItem_ClearOutputAllChildCalculationsAndNotifyCalculationObservers(bool confirm) + public void ContextMenuStrip_ClickOnClearOutputItem_ClearOutputAllChildCalculationsAndNotifyCalculationObservers(bool confirm) { // Setup var gui = mocks.StrictMock(); @@ -1269,13 +758,13 @@ var emptyChildGroup = new PipingCalculationGroup(); var group = new PipingCalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + @group.Children.Add(childGroup); + @group.Children.Add(emptyChildGroup); + @group.Children.Add(calculation2); var pipingFailureMechanismMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); @@ -1302,79 +791,624 @@ }; // Precondition - Assert.IsTrue(group.HasOutput); + Assert.IsTrue(@group.HasOutput); var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); // Call contextMenu.Items[contextMenuClearOutputIndex].PerformClick(); // Assert - Assert.AreNotEqual(confirm, group.HasOutput); + Assert.AreNotEqual(confirm, @group.HasOutput); Assert.AreNotEqual(confirm, calculation1.HasOutput); Assert.AreNotEqual(confirm, calculation2.HasOutput); mocks.VerifyAll(); } [Test] - public void GetChildNodeObjects_EmptyGroup_ReturnEmpty() + public void CanRenameNode_ParentIsPipingFailureMechanismNode_ReturnFalse() { // Setup + var failureMechanism = new PipingFailureMechanism(); + + mocks.ReplayAll(); + + // Call + bool isRenamingAllowed = info.CanRename(null, failureMechanism); + + // Assert + Assert.IsFalse(isRenamingAllowed); + mocks.VerifyAll(); + } + + [Test] + public void CanRenameNode_EverythingElse_ReturnTrue() + { + // Call + bool isRenamingAllowed = info.CanRename(null, null); + + // Assert + Assert.IsTrue(isRenamingAllowed); + mocks.VerifyAll(); + } + + [Test] + public void OnNodeRenamed_WithData_RenameGroupAndNotifyObservers() + { + // Setup + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); mocks.ReplayAll(); - var groupContext = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanismMock); + var nodeData = new PipingCalculationGroupContext(@group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + nodeData.Attach(observer); // Call - var children = info.ChildNodeObjects(groupContext); + const string newName = "new name"; + info.OnNodeRenamed(nodeData, newName); // Assert - CollectionAssert.IsEmpty(children); + Assert.AreEqual(newName, @group.Name); + mocks.VerifyAll(); } [Test] - public void GetChildNodeObjects_GroupWithMixedContents_ReturnChildren() + public void CanRemove_ParentIsFailureMechanism_ReturnFalse() { // Setup - var calculationItem = mocks.StrictMock(); + var group = new PipingCalculationGroup(); + var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); - var childCalculation = new PipingCalculation(); + var nodeData = new PipingCalculationGroupContext(@group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); - var childGroup = new PipingCalculationGroup(); + var parentNodeData = new PipingFailureMechanism(); + parentNodeData.CalculationsGroup.Children.Add(@group); + mocks.ReplayAll(); + + // Call + bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); + + // Assert + Assert.IsFalse(isRemovalAllowed); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_ParentIsPipingCalculationGroupContainingGroup_ReturnTrue() + { + // Setup var group = new PipingCalculationGroup(); - group.Children.Add(calculationItem); - group.Children.Add(childCalculation); - group.Children.Add(childGroup); + var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); + var nodeData = new PipingCalculationGroupContext(@group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + var parentGroup = new PipingCalculationGroup(); + parentGroup.Children.Add(@group); + var parentNodeData = new PipingCalculationGroupContext(parentGroup, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + mocks.ReplayAll(); + + // Call + bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); + + // Assert + Assert.IsTrue(isRemovalAllowed); + mocks.VerifyAll(); + } + + [Test] + public void CanRemove_ParentIsPipingCalculationGroupNotContainingGroup_ReturnFalse() + { + // Setup + var group = new PipingCalculationGroup(); var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); + var nodeData = new PipingCalculationGroupContext(@group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + var parentGroup = new PipingCalculationGroup(); + var parentNodeData = new PipingCalculationGroupContext(parentGroup, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + // Precondition + CollectionAssert.DoesNotContain(parentGroup.Children, @group); + + // Call + bool isRemovalAllowed = info.CanRemove(nodeData, parentNodeData); + + // Assert + Assert.IsFalse(isRemovalAllowed); + } + + [Test] + public void OnNodeRemoved_ParentIsPipingCalculationGroupContainingGroup_RemoveGroupAndNotifyObservers() + { + // Setup + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + var group = new PipingCalculationGroup(); + var pipingFailureMechanismMock = mocks.StrictMock(); mocks.ReplayAll(); - var nodeData = new PipingCalculationGroupContext(group, + var nodeData = new PipingCalculationGroupContext(@group, Enumerable.Empty(), Enumerable.Empty(), pipingFailureMechanismMock); + var parentGroup = new PipingCalculationGroup(); + parentGroup.Children.Add(@group); + var parentNodeData = new PipingCalculationGroupContext(parentGroup, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + parentNodeData.Attach(observer); + + // Precondition + Assert.IsTrue(info.CanRemove(nodeData, parentNodeData)); + // Call - var children = info.ChildNodeObjects(nodeData).ToArray(); + info.OnNodeRemoved(nodeData, parentNodeData); // Assert - Assert.AreEqual(group.Children.Count, children.Length); - Assert.AreSame(calculationItem, children[0]); - var returnedCalculationContext = (PipingCalculationContext) children[1]; - Assert.AreSame(childCalculation, returnedCalculationContext.WrappedData); - Assert.AreSame(pipingFailureMechanismMock, returnedCalculationContext.PipingFailureMechanism); - var returnedCalculationGroupContext = (PipingCalculationGroupContext)children[2]; - Assert.AreSame(childGroup, returnedCalculationGroupContext.WrappedData); - Assert.AreSame(pipingFailureMechanismMock, returnedCalculationGroupContext.PipingFailureMechanism); + CollectionAssert.DoesNotContain(parentGroup.Children, @group); mocks.VerifyAll(); } + [Test] + public void CanDrag_WithParentNodeDefaultBehavior_ReturnTrue() + { + // Setup + var group = new PipingCalculationGroup(); + var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var groupContext = new PipingCalculationGroupContext(group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + // Call + var canDrag = info.CanDrag(groupContext, null); + + // Assert + Assert.IsTrue(canDrag); + } + + [Test] + public void CanDrag_ParentIsPipingFailureMechanism_ReturnFalse() + { + // Setup + var pipingFailureMechanism = new PipingFailureMechanism(); + var group = pipingFailureMechanism.CalculationsGroup; + var pipingFailureMechanismMock = mocks.StrictMock(); + mocks.ReplayAll(); + + var groupContext = new PipingCalculationGroupContext(group, + Enumerable.Empty(), + Enumerable.Empty(), + pipingFailureMechanismMock); + + // Call + var canDrag = info.CanDrag(groupContext, pipingFailureMechanism); + + // Assert + Assert.IsFalse(canDrag); + } + + [Test] + [Combinatorial] + public void CanDropOrCanInsert_DraggingPipingCalculationItemContextOntoGroupNotContainingItem_ReturnMoveOrTrue( + [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, + [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) + { + // Setup + IPipingCalculationItem draggedItem; + object draggedItemContext; + + var failureMechanism = new PipingFailureMechanism(); + + CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, failureMechanism); + + PipingCalculationGroup targetGroup; + PipingCalculationGroupContext targetGroupContext; + CreatePipingCalculationGroupAndContext(out targetGroup, out targetGroupContext, failureMechanism); + + failureMechanism.CalculationsGroup.Children.Add(draggedItem); + failureMechanism.CalculationsGroup.Children.Add(targetGroup); + + switch (methodToTest) + { + case DragDropTestMethod.CanDrop: + // Call + var canDrop = info.CanDrop(draggedItemContext, targetGroupContext); + + // Assert + Assert.IsTrue(canDrop); + break; + case DragDropTestMethod.CanInsert: + // Call + bool canInsert = info.CanInsert(draggedItemContext, targetGroupContext); + + // Assert + Assert.IsTrue(canInsert); + break; + default: + Assert.Fail(methodToTest + " not supported."); + break; + } + mocks.VerifyAll(); + } + + [Test] + [Combinatorial] + public void CanDropOrInsert_DraggingCalculationItemContextOntoGroupNotContainingItemOtherFailureMechanism_ReturnNoneOrFalse( + [Values(DragDropTestMethod.CanDrop, DragDropTestMethod.CanInsert)] DragDropTestMethod methodToTest, + [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) + { + // Setup + IPipingCalculationItem draggedItem; + object draggedItemContext; + + var targetFailureMechanism = new PipingFailureMechanism(); + + CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, targetFailureMechanism); + + var sourceFailureMechanism = new PipingFailureMechanism(); + sourceFailureMechanism.CalculationsGroup.Children.Add(draggedItem); + + PipingCalculationGroup targetGroup; + PipingCalculationGroupContext targetGroupContext; + CreatePipingCalculationGroupAndContext(out targetGroup, out targetGroupContext, sourceFailureMechanism); + + targetFailureMechanism.CalculationsGroup.Children.Add(targetGroup); + + switch (methodToTest) + { + case DragDropTestMethod.CanDrop: + // Call + var canDrop = info.CanDrop(draggedItemContext, targetGroupContext); + + // Assert + Assert.IsFalse(canDrop); + break; + case DragDropTestMethod.CanInsert: + // Call + bool canInsert = info.CanInsert(draggedItemContext, targetGroupContext); + + // Assert + Assert.IsFalse(canInsert); + break; + default: + Assert.Fail(methodToTest + " not supported."); + break; + } + mocks.VerifyAll(); + } + + + +// [Test] +// [Combinatorial] +// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupEnd_MoveCalculationItemInstanceToNewGroup( +// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) +// { +// // Setup +// IPipingCalculationItem draggedItem; +// object draggedItemContext; +// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); +// +// PipingCalculationGroup originalOwnerGroup; +// PipingCalculationGroupContext originalOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); +// originalOwnerGroup.Children.Add(draggedItem); +// +// PipingCalculationGroup newOwnerGroup; +// PipingCalculationGroupContext newOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); +// +// var originalOwnerObserver = mocks.StrictMock(); +// originalOwnerObserver.Expect(o => o.UpdateObserver()); +// +// var updatewasCalled = false; +// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updatewasCalled = true); +// +// var newOwnerGroupContextNode = new TreeNode +// { +// Tag = newOwnerGroupContext +// }; +// +// var originalOwnerGroupContextNode = new TreeNode +// { +// Tag = originalOwnerGroupContext +// }; +// +// var draggedItemContextNode = new TreeNode +// { +// Tag = draggedItemContext +// }; +// draggedItemContextNode.Collapse(); +// +// newOwnerGroupContextNode.Nodes.Add(draggedItemContextNode); +// +// mocks.ReplayAll(); +// +// var treeView = new Core.Common.Controls.TreeView.TreeView(); +// var root = new TreeNode(); +// treeView.Nodes.Add(root); +// root.Nodes.Add(originalOwnerGroupContextNode); +// root.Nodes.Add(newOwnerGroupContextNode); +// +// originalOwnerGroup.Attach(originalOwnerObserver); +// newOwnerGroup.Attach(newOwnerObserver); +// +// // Precondition: +// Assert.IsFalse(draggedItemContextNode.IsExpanded); +// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); +// +// // Call +// info.OnDrop(draggedItemContextNode, newOwnerGroupContextNode, newOwnerGroup.Children.Count); +// +// // Assert +// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); +// Assert.AreSame(draggedItem, newOwnerGroup.Children.Last(), +// "Dragging node at the end of the target PipingCalculationGroup should put the dragged data at the end of 'newOwnerGroup'."); +// +// Assert.AreSame(draggedItemContextNode, draggedItemContextNode.TreeView.SelectedNode); +// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); +// Assert.IsFalse(draggedItemContextNode.IsExpanded); +// +// mocks.VerifyAll(); +// } +// +// [Test] +// [Combinatorial] +// public void OnDragDrop_InsertingPipingCalculationItemContextAtDifferentLocationWithingSameGroup_ChangeItemIndexOfCalculationItem( +// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType, +// [Values(0, 2)] int newIndex) +// { +// // Setup +// const string name = "Very cool name"; +// IPipingCalculationItem draggedItem; +// object draggedItemContext; +// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext, name); +// +// var existingItemStub = mocks.Stub(); +// existingItemStub.Stub(i => i.Name).Return(""); +// +// PipingCalculationGroup originalOwnerGroup; +// PipingCalculationGroupContext originalOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); +// originalOwnerGroup.Children.Add(existingItemStub); +// originalOwnerGroup.Children.Add(draggedItem); +// originalOwnerGroup.Children.Add(existingItemStub); +// +// bool updatewasCalled = false; +// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updatewasCalled = true); +// +// var existingItemStub1 = CreateStubTreeNode(); +// var existingItemStub2 = CreateStubTreeNode(); +// +// var preUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); +// var postUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); +// TreeNode[] preUpdateNewOwnerChildNodes = { existingItemStub1, preUpdateDraggedItemContextNode, existingItemStub2 }; +// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(originalOwnerGroupContext, preUpdateNewOwnerChildNodes, invocation => +// { +// if (updatewasCalled) +// { +// invocation.ReturnValue = new[] +// { +// existingItemStub1, +// postUpdateDraggedItemContextNode, +// existingItemStub2 +// }; +// } +// }); +// postUpdateDraggedItemContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); +// +// mocks.ReplayAll(); +// +// originalOwnerGroup.Attach(originalOwnerObserver); +// +// // Precondition: +// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); +// +// // Call +// info.OnDrop(preUpdateDraggedItemContextNode, newOwnerGroupContextNode, newIndex); +// +// // Assert +// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); +// Assert.AreNotSame(draggedItem, originalOwnerGroup.Children[1], +// "Should have removed 'draggedItem' from its original location in the collection."); +// Assert.AreSame(draggedItem, originalOwnerGroup.Children[newIndex], +// "Dragging node to specific location within owning PipingCalculationGroup should put the dragged data at that index."); +// Assert.AreEqual(name, draggedItem.Name, +// "No renaming should occur when dragging within the same PipingCalculationGroup."); +// +// Assert.AreSame(postUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode.TreeView.SelectedNode); +// +// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); +// +// mocks.VerifyAll(); +// } +// +// [Test] +// [Combinatorial] +// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupStartWithSameNamedItem_MoveCalculationItemInstanceToNewGroupAndRename( +// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) +// { +// // Setup +// IPipingCalculationItem draggedItem; +// object draggedItemContext; +// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); +// +// PipingCalculationGroup originalOwnerGroup; +// PipingCalculationGroupContext originalOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); +// originalOwnerGroup.Children.Add(draggedItem); +// +// PipingCalculationGroup newOwnerGroup; +// PipingCalculationGroupContext newOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); +// +// var sameNamedItem = mocks.Stub(); +// sameNamedItem.Stub(i => i.Name).Return(draggedItem.Name); +// +// var updateWasCalled = false; +// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(); +// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(invocation => updateWasCalled = true); +// +// var preUpdateCalculationContextNode = CreateExpandedNodeStub(draggedItemContext, new TreeNode[0]); +// var postUpdateCalculationContextNode = CreateNodeStubToBeExpanded(draggedItemContext, new TreeNode[0]); +// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(originalOwnerGroupContext, new TreeNode[0], invocation => +// { +// if (updateWasCalled) +// { +// invocation.ReturnValue = new[] +// { +// postUpdateCalculationContextNode +// }; +// } +// }); +// postUpdateCalculationContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); +// +// mocks.ReplayAll(); +// +// newOwnerGroup.Children.Add(sameNamedItem); +// +// originalOwnerGroup.Attach(originalOwnerObserver); +// newOwnerGroup.Attach(newOwnerObserver); +// +// // Precondition: +// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); +// CollectionAssert.Contains(newOwnerGroup.Children.Select(c => c.Name), draggedItem.Name, +// "Name of the dragged item should already exist in new owner."); +// +// // Call +// info.OnDrop(preUpdateCalculationContextNode, newOwnerGroupContextNode, 0); +// +// // Assert +// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); +// Assert.AreSame(draggedItem, newOwnerGroup.Children.First(), +// "Dragging to insert node at start of newOwnerGroup should place the node at the start of the list."); +// switch (draggedItemType) +// { +// case PipingCalculationItemType.Calculation: +// Assert.AreEqual("Nieuwe berekening (1)", draggedItem.Name); +// break; +// case PipingCalculationItemType.Group: +// Assert.AreEqual("Nieuwe map (1)", draggedItem.Name); +// break; +// } +// +// Assert.AreSame(postUpdateCalculationContextNode, postUpdateCalculationContextNode.TreeView.SelectedNode); +// +// Assert.IsTrue(postUpdateCalculationContextNode.IsExpanded); +// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); +// +// mocks.VerifyAll(); +// } +// +// [Test] +// [Combinatorial] +// public void OnDragDrop_DraggingPipingCalculationItemContextOntoGroupWithOtherItems_ExpandedCollapsedStateOfOtherItemsRestored( +// [Values(PipingCalculationItemType.Calculation, PipingCalculationItemType.Group)] PipingCalculationItemType draggedItemType) +// { +// // Setup +// IPipingCalculationItem draggedItem; +// object draggedItemContext; +// CreatePipingCalculationItemAndContext(draggedItemType, out draggedItem, out draggedItemContext); +// +// PipingCalculationGroup originalOwnerGroup; +// PipingCalculationGroupContext originalOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out originalOwnerGroup, out originalOwnerGroupContext); +// originalOwnerGroup.Children.Add(draggedItem); +// +// PipingCalculationGroup newOwnerGroup; +// PipingCalculationGroupContext newOwnerGroupContext; +// CreatePipingCalculationGroupAndContext(out newOwnerGroup, out newOwnerGroupContext); +// +// var updatewasCalled = false; +// var originalOwnerObserver = CreateObserverStubWithUpdateExpectancy(); +// var newOwnerObserver = CreateObserverStubWithUpdateExpectancy(methodInvocation => updatewasCalled = true); +// +// var nodeStub = CreateStubTreeNode(); +// TreeNode[] childNodesStub = { nodeStub }; +// +// var expandedNodeData = new object(); +// var preUpdateExpandedNode = CreateExpandedNodeStub(expandedNodeData, childNodesStub); +// var postUpdateExpandedNode = CreateNodeStubToBeExpanded(expandedNodeData, childNodesStub); +// +// var collapsedNodeData = new object(); +// var preUpdateCollapsedNode = CreateCollapsedNodeStub(collapsedNodeData, childNodesStub); +// var postUpdateCollapsedNode = CreateNodeStubToBeCollapsed(collapsedNodeData, childNodesStub); +// +// TreeNode[] preUpdateChildNodes = { preUpdateExpandedNode, preUpdateCollapsedNode }; +// TreeNode[] postUpdateChildNodes = { postUpdateExpandedNode, postUpdateCollapsedNode }; +// var newOwnerGroupContextNode = CreateNodeStubToBeExpanded(newOwnerGroupContext, preUpdateChildNodes, invocation => +// { +// if (updatewasCalled) +// { +// invocation.ReturnValue = postUpdateChildNodes; +// } +// }); +// +// var preUpdateDraggedItemContextNode = CreateTreeNodeLeafForData(draggedItemContext); +// var postUpdateDraggedItemContextNode = CreateNodeStubToBeCollapsed(draggedItemContext, new TreeNode[0]); +// postUpdateDraggedItemContextNode.Expect(n => n.Parent).Return(newOwnerGroupContextNode); +// +// mocks.ReplayAll(); +// +// originalOwnerGroup.Attach(originalOwnerObserver); +// newOwnerGroup.Attach(newOwnerObserver); +// +// // Precondition: +// CollectionAssert.Contains(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.DoesNotContain(newOwnerGroup.Children, draggedItem); +// +// // Call +// info.OnDrop(preUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode, newOwnerGroup.Children.Count); +// +// // Assert +// CollectionAssert.DoesNotContain(originalOwnerGroup.Children, draggedItem); +// CollectionAssert.Contains(newOwnerGroup.Children, draggedItem); +// Assert.AreSame(draggedItem, newOwnerGroup.Children.Last(), +// "Dragging node at the end of the target PipingCalculationGroup should put the dragged data at the end of 'newOwnerGroup'."); +// +// Assert.AreSame(postUpdateDraggedItemContextNode, postUpdateDraggedItemContextNode.TreeView.SelectedNode); +// Assert.IsFalse(postUpdateCollapsedNode.IsExpanded); +// Assert.IsFalse(postUpdateDraggedItemContextNode.IsExpanded); +// Assert.IsTrue(postUpdateExpandedNode.IsExpanded); +// Assert.IsTrue(newOwnerGroupContextNode.IsExpanded); +// +// mocks.VerifyAll(); +// } + private const int contextMenuAddCalculationGroupIndex = 0; private const int contextMenuAddCalculationIndex = 1; private const int contextMenuValidateAllIndex = 3; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs =================================================================== diff -u -rd03f2b52982110a0f804adfefe73f86551c59e62 -rc96f5829ddb898717ba2e98091a2219308f05d3e --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision d03f2b52982110a0f804adfefe73f86551c59e62) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismTreeNodeInfoTest.cs (.../PipingFailureMechanismTreeNodeInfoTest.cs) (revision c96f5829ddb898717ba2e98091a2219308f05d3e) @@ -86,7 +86,7 @@ } [Test] - public void GetChildNodeObjects_Always_ReturnChildDataNodes() + public void ChildNodeObjects_Always_ReturnChildDataNodes() { // Setup var pipingFailureMechanism = new PipingFailureMechanism();