Пример #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));
        }
Пример #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");
        }
Пример #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");
        }
Пример #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");
        }
Пример #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");
        }
Пример #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");
        }
Пример #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");
        }
Пример #8
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");
        }
Пример #9
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");
        }