示例#1
0
        public void CompareTo_Should_ReturnZero_When_GOrdersAreEqualInTheMainValuesAndInTheNestedValues()
        {
            HierarchicalOrder mainHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder mainNested            = new HierarchicalOrder(1);

            mainHierarchicalOrder.AddAsLastElementHierarchicalOrder(mainNested);

            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder otherNested            = new HierarchicalOrder(1);

            otherHierarchicalOrder.AddAsLastElementHierarchicalOrder(otherNested);

            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(0, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
示例#2
0
        public void CompareTo_Should_ReturnOne_When_TheFirstGOGreaterThanTheSecondOne_And_TheNestedOnesHaveSameValues()
        {
            HierarchicalOrder mainHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder mainNested            = new HierarchicalOrder(1);

            mainHierarchicalOrder.AddAsLastElementHierarchicalOrder(mainNested);

            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(1);
            HierarchicalOrder otherNested            = new HierarchicalOrder(1);

            otherHierarchicalOrder.AddAsLastElementHierarchicalOrder(otherNested);

            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(1, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
示例#3
0
        public void CompareTo_Should_ReturnOneMinus_When_TheMainValuesAreEqualsAndTheFirstNestedValueIsLowerThanTheSecondOne()
        {
            HierarchicalOrder mainHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder mainNested            = new HierarchicalOrder(1);

            mainHierarchicalOrder.AddAsLastElementHierarchicalOrder(mainNested);

            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder otherNested            = new HierarchicalOrder(2);

            otherHierarchicalOrder.AddAsLastElementHierarchicalOrder(otherNested);

            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(-1, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
示例#4
0
        public void CompareTo_Should_ReturnOneMinus_When_TheFirstGOHaveAThirdNestedGOAndTheSecondHaventItWithTheOtherValuesEqual()
        {
            HierarchicalOrder mainHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder mainNested            = new HierarchicalOrder(1);

            mainHierarchicalOrder.AddAsLastElementHierarchicalOrder(mainNested);
            HierarchicalOrder mainNestedNested = new HierarchicalOrder(3);

            mainNested.AddAsLastElementHierarchicalOrder(mainNestedNested);

            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder otherNested            = new HierarchicalOrder(1);

            otherHierarchicalOrder.AddAsLastElementHierarchicalOrder(otherNested);

            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(-1, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
示例#5
0
        public void CompareTo_Should_ReturnZero_When_TheMainAndTheNestedValuesOfTheFirstGOAreAllEqualThanTheSecondOne()
        {
            HierarchicalOrder mainHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder mainNested            = new HierarchicalOrder(1);

            mainHierarchicalOrder.AddAsLastElementHierarchicalOrder(mainNested);
            HierarchicalOrder mainNestedNested = new HierarchicalOrder(2);

            mainNested.AddAsLastElementHierarchicalOrder(mainNestedNested);

            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            HierarchicalOrder otherNested            = new HierarchicalOrder(1);

            otherHierarchicalOrder.AddAsLastElementHierarchicalOrder(otherNested);
            HierarchicalOrder otherNestedNested = new HierarchicalOrder(2);

            otherNested.AddAsLastElementHierarchicalOrder(otherNestedNested);

            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(0, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }