Ejemplo n.º 1
0
        public void ClonesChildren()
        {
            var child = new Node("c1");
            var parent = new ClassNode(null, null, 1);
            parent.AddChild(child);
            var parent2 = parent.DeepClone();

            //Assert
            parent2.Childs.Should()
                .NotBeEmpty()
                .And.NotContain(child);
            parent2.Childs.First().Name.Should().Be("c1");
        }
Ejemplo n.º 2
0
        public void ModifyingClonedTreeDoesNotModifyOriginal()
        {
            var originalChild1 = new Node("c1");
            var parent = new ClassNode(null, null, 1);
            parent.AddChild(originalChild1);

            var clonedParent = parent.DeepClone();
            var clonedParent2 = parent.DeepClone();
            clonedParent.FilterAllChilds();

            // Assert:
            clonedParent.Childs.Should().BeEmpty();
            clonedParent2.Childs.Should().NotBeEmpty();
        }
Ejemplo n.º 3
0
        public void ClonesDependencies()
        {
            var originalChild1 = new Node("c1");
            var originalChild2 = new Node("c2");
            var parent = new ClassNode(null, null, 1);
            parent.AddChild(originalChild1);
            parent.AddChild(originalChild2);
            originalChild1.Dependencies.Add(originalChild2);

            var parent2 = parent.DeepClone();

            var clonedChild1 = parent2.Childs.WithName("c1");
            var clonedChild2 = parent2.Childs.WithName("c2");
            //Assert
            clonedChild1.Dependencies.Should()
                .Contain(clonedChild2)
                .And
                .NotContain(originalChild2);
        }
Ejemplo n.º 4
0
 public static bool ShouldBeRemoved(ClassNode node,int x)
 {
     return node.NrOfMethods < x;
 }
Ejemplo n.º 5
0
 private static void CreateDependency(ClassNode nodeDependantOn, Node dependor)
 {
     nodeDependantOn.References.Add(dependor);
     dependor.Dependencies.Add(nodeDependantOn);
 }
Ejemplo n.º 6
0
 private static bool ShouldBeRemoved(ClassNode arg1, int arg2)
 {
     return arg1.References.Count < arg2;
 }