Exemple #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");
        }
Exemple #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();
        }
Exemple #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);
        }
Exemple #4
0
 public static bool ShouldBeRemoved(ClassNode node,int x)
 {
     return node.NrOfMethods < x;
 }
 private static void CreateDependency(ClassNode nodeDependantOn, Node dependor)
 {
     nodeDependantOn.References.Add(dependor);
     dependor.Dependencies.Add(nodeDependantOn);
 }
Exemple #6
0
 private static bool ShouldBeRemoved(ClassNode arg1, int arg2)
 {
     return arg1.References.Count < arg2;
 }