public void AddRemoveNodeRemoveApplyAndRevertWhenNodeHas2OutputsApplyAndRevertTest() { Node parent1 = new Node(NodeType.add, 0); Node parent2 = new Node(NodeType.compare, 0); Node nodeToBeRemoved = new Node(NodeType.inverse, 0); Node output1 = new Node(NodeType.log, 0); Node output2 = new Node(NodeType.log, 0); parent1.ConnectWithOutput(nodeToBeRemoved); parent2.ConnectWithOutput(nodeToBeRemoved); nodeToBeRemoved.ConnectWithOutput(output1); nodeToBeRemoved.ConnectWithOutput(output2); dummyNetwork.Operations.Add(parent1); dummyNetwork.Operations.Add(parent2); dummyNetwork.Operations.Add(output1); dummyNetwork.Operations.Add(output2); dummyNetwork.Operations.Add(nodeToBeRemoved); AddRemoveNode mutator = new AddRemoveNode( nodeChangeType: AddRemoveNode.NodeChangeType.Remove, node: nodeToBeRemoved, parent1: parent1, parent2: parent2, outputs: new List <Node>(nodeToBeRemoved.Outputs), network: dummyNetwork); mutator.Apply(); mutator.Revert(); Assert.AreEqual(0, parent1.Inputs.Count); Assert.AreEqual(1, parent1.Outputs.Count); Assert.IsNotNull(parent1.Outputs.Find(nodeToBeRemoved)); Assert.AreEqual(0, parent2.Inputs.Count); Assert.AreEqual(1, parent2.Outputs.Count); Assert.IsNotNull(parent2.Outputs.Find(nodeToBeRemoved)); Assert.AreEqual(2, nodeToBeRemoved.Inputs.Count); Assert.IsNotNull(nodeToBeRemoved.Inputs.Find(parent1)); Assert.IsNotNull(nodeToBeRemoved.Inputs.Find(parent2)); Assert.AreEqual(2, nodeToBeRemoved.Outputs.Count); Assert.AreEqual(output1, nodeToBeRemoved.Outputs.First.Value); Assert.AreEqual(output2, nodeToBeRemoved.Outputs.Last.Value); Assert.AreEqual(1, output1.Inputs.Count); Assert.IsNotNull(output1.Inputs.Find(nodeToBeRemoved)); Assert.AreEqual(0, output1.Outputs.Count); Assert.AreEqual(1, output2.Inputs.Count); Assert.IsNotNull(output2.Inputs.Find(nodeToBeRemoved)); Assert.AreEqual(0, output2.Outputs.Count); dummyNetwork.UTTestingFoo(); }
public void AddRemoveNodeRemoveApplyAndRevertWhenSecondParentHas2AndNodeToRemoveIsLastOneChildrenTest() { Node parent1 = new Node(NodeType.add, 0); Node parent2 = new Node(NodeType.compare, 0); Node child1 = new Node(NodeType.copy, 0); Node nodeToBeRemoved = new Node(NodeType.inverse, 0); Node output = new Node(NodeType.log, 0); parent1.ConnectWithOutput(nodeToBeRemoved); parent2.ConnectWithOutput(child1); parent2.ConnectWithOutput(nodeToBeRemoved); nodeToBeRemoved.ConnectWithOutput(output); dummyNetwork.Operations.Add(parent1); dummyNetwork.Operations.Add(parent2); dummyNetwork.Operations.Add(output); dummyNetwork.Operations.Add(child1); dummyNetwork.Operations.Add(nodeToBeRemoved); AddRemoveNode mutator = new AddRemoveNode( nodeChangeType: AddRemoveNode.NodeChangeType.Remove, node: nodeToBeRemoved, parent1: parent1, parent2: parent2, outputs: new List <Node>(nodeToBeRemoved.Outputs), network: dummyNetwork); mutator.Apply(); mutator.Revert(); Assert.AreEqual(0, parent1.Inputs.Count); Assert.AreEqual(1, parent1.Outputs.Count); Assert.IsTrue(parent1.Outputs.Contains(nodeToBeRemoved)); Assert.AreEqual(2, nodeToBeRemoved.Inputs.Count); Assert.AreEqual(parent1, nodeToBeRemoved.Inputs.First.Value); Assert.AreEqual(parent2, nodeToBeRemoved.Inputs.Last.Value); Assert.AreEqual(1, nodeToBeRemoved.Outputs.Count); Assert.AreEqual(output, nodeToBeRemoved.Outputs.First.Value); Assert.AreEqual(0, parent2.Inputs.Count); Assert.AreEqual(2, parent2.Outputs.Count); Assert.AreEqual(child1, parent2.Outputs.First.Value); Assert.AreEqual(nodeToBeRemoved, parent2.Outputs.Last.Value); Assert.AreEqual(1, output.Inputs.Count); Assert.AreEqual(nodeToBeRemoved, output.Inputs.First.Value); Assert.AreEqual(0, output.Outputs.Count); Assert.AreEqual(1, child1.Inputs.Count); Assert.AreEqual(parent2, child1.Inputs.First.Value); Assert.AreEqual(0, child1.Outputs.Count); dummyNetwork.UTTestingFoo(); }
public void AddRemoveNodeAddApplyAndRevertTest() { Node parent1 = new Node(NodeType.add, 0); Node parent2 = new Node(NodeType.add, 0); Node output = new Node(NodeType.add, 0); parent1.ConnectWithOutput(output); dummyNetwork.Operations.Add(parent1); dummyNetwork.Operations.Add(parent2); dummyNetwork.Operations.Add(output); Node nodeToBeAdded = new Node(NodeType.add, 0); AddRemoveNode mutator = new AddRemoveNode( nodeChangeType: AddRemoveNode.NodeChangeType.Add, node: nodeToBeAdded, parent1: parent1, parent2: parent2, outputs: new List <Node>() { output }, network: dummyNetwork); mutator.Apply(); mutator.Revert(); Assert.AreEqual(0, parent1.Inputs.Count); Assert.AreEqual(1, parent1.Outputs.Count); Assert.IsNotNull(parent1.Outputs.Find(output)); Assert.AreEqual(0, parent2.Inputs.Count); Assert.AreEqual(0, parent2.Outputs.Count); Assert.AreEqual(1, output.Inputs.Count); Assert.IsNotNull(output.Inputs.Find(parent1)); Assert.AreEqual(0, output.Outputs.Count); }