Exemple #1
0
        /// <summary>
        /// Compares to.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns>0 if the objects are equals, -1 if <see cref="this"/> is lower than <paramref name="other"/> and 1 if <see cref="this"/> is greater than <paramref name="other"/> </returns>
        public int CompareTo(FullMethodDescription other)
        {
            HierarchicalOrder mainHierarchicalOrder  = this.GetHierarchicalOrder();
            HierarchicalOrder otherHierarchicalOrder = other.GetHierarchicalOrder();

            return(mainHierarchicalOrder.CompareTo(otherHierarchicalOrder));
        }
Exemple #2
0
        public void CompareTo_Should_ReturnOneMinus_When_TheFirstGOIsLowerThanTheSecondOne()
        {
            HierarchicalOrder mainHierarchicalOrder  = new HierarchicalOrder(1);
            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(-1, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
Exemple #3
0
        public void CompareTo_Should_ReturnZero_When_TheTwoGOHaveTheSameValue()
        {
            HierarchicalOrder mainHierarchicalOrder  = new HierarchicalOrder(2);
            HierarchicalOrder otherHierarchicalOrder = new HierarchicalOrder(2);
            int result = mainHierarchicalOrder.CompareTo(otherHierarchicalOrder);

            Assert.AreEqual(0, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
Exemple #4
0
        public void CompareTo_Should_ReturnOne_When_TheFirstGOIsGreaterThanTheSecondOne()
        {
            HierarchicalOrder greaterHierarchicalOrder = new HierarchicalOrder(2);

            HierarchicalOrder lowerHierarchicalOrder = new HierarchicalOrder(1);

            int result = greaterHierarchicalOrder.CompareTo(lowerHierarchicalOrder);

            Assert.AreEqual(1, result, "The comparison between the two HierarchicalOrder objects returns a wrong answer");
        }
Exemple #5
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");
        }
Exemple #6
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");
        }
Exemple #7
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");
        }
Exemple #8
0
        /// <summary>
        /// Calculates the hierarchical order using the <see cref="this.SuccessionOrder"/> value of its parents.
        /// </summary>
        /// <returns>Returns the root of the tree formed by <see cref="HierarchicalOrder"/> objects.</returns>
        private HierarchicalOrder GetHierarchicalOrder()
        {
            HierarchicalOrder result;
            HierarchicalOrder hierarchicalOrder = new HierarchicalOrder(this.SuccessionOrder);

            if (this.MainMethod != null)
            {
                result = this.MainMethod.GetHierarchicalOrder();
                result.AddAsLastElementHierarchicalOrder(hierarchicalOrder);
            }
            else
            {
                result = hierarchicalOrder;
            }

            return(result);
        }
Exemple #9
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");
        }
Exemple #10
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");
        }