Ejemplo n.º 1
0
        private AssociativeTreeNode <T> GetRootFromAssociativeTree(AssociativeTree <T> tree)
        {
            var root = typeof(AssociativeTree <T>)
                       .GetProperty("Root", BindingFlags.Instance | BindingFlags.Public)
                       .GetValue(tree) as AssociativeTreeNode <T>;

            return(root);
        }
Ejemplo n.º 2
0
        private AssociativeTreeNode <T>[] GetArrayFromAssociativeTree(AssociativeTree <T> tree)
        {
            var array = typeof(AssociativeTree <T>)
                        .GetField("AssociativeTreeNodes", BindingFlags.NonPublic | BindingFlags.Instance)
                        .GetValue(tree) as AssociativeTreeNode <T>[];

            return(array);
        }
Ejemplo n.º 3
0
        public void CreateTreeInvalidTest(params int[] arr)
        {
            //arrange
            ITree <Int32> tree = new AssociativeTree <int>(arr.First());


            //result
            Assert.ThrowsException <TreeException>(() =>
            {
                arr.Skip(1).ToList().ForEach(value => tree.AddNode(value));
            });
        }
Ejemplo n.º 4
0
        public void CreateTreeValidTest(params int[] arr)
        {
            //arrange
            ITree <Int32> tree = new AssociativeTree <int>(arr.First());


            //act
            arr.Skip(1).ToList().ForEach(value => tree.AddNode(value));

            //result
            Assert.IsTrue(tree != null);
        }
Ejemplo n.º 5
0
        public void TreeGetMaxNodeTest(params int[] arr)
        {
            //arrange
            ITree <Int32> tree = new AssociativeTree <int>(arr.First());

            //act
            arr.Skip(1).ToList().ForEach(value => tree.AddNode(value));
            int result = tree.GetMaxNode();


            //assert
            Assert.IsTrue(result == arr.Max());
        }
Ejemplo n.º 6
0
        public void TreeDeleteNodesTest(int elementForDelete, params int[] arr)
        {
            //arrange
            AssociativeTree <Int32> tree = new AssociativeTree <int>(arr.First());

            //act
            arr.Skip(1).ToList().ForEach(value => tree.AddNode(value));
            tree.DeleteNode(elementForDelete);


            //assert
            Assert.IsTrue(!tree.Contains(elementForDelete) && tree.Count == (arr.Length - 1));
        }
Ejemplo n.º 7
0
        public void TreeContainsTest(int element, params int[] arr)
        {
            //arrange
            ITree <Int32> tree = new AssociativeTree <int>(arr.First());

            //act
            arr.Skip(1).ToList().ForEach(value => tree.AddNode(value));
            bool result = tree.Contains(element);


            //assert
            Assert.IsTrue(result == arr.Contains(element));
        }
Ejemplo n.º 8
0
 public AssociativeTreeFinder(AssociativeTree <T> tree)
 {
     Tree = tree ?? throw new ArgumentNullException("Tree can't be null!!!");
 }
 public AssociativeTreeLeavesRemover(AssociativeTree <T> associativeTree)
 {
     Tree = associativeTree ?? throw new ArgumentNullException("Tree can't be null!!!");
 }