예제 #1
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));
            });
        }
예제 #2
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);
        }
예제 #3
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());
        }
예제 #4
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));
        }
예제 #5
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));
        }