Beispiel #1
0
        public void EqualityTest()
        {
            var p1 = new Prefix(_prefixConfig, "DEV", "iphone");
            var p2 = new Prefix(_prefixConfig, "DEV");
            var p3 = new Prefix(_prefixConfig, "stageB");
            var p4 = new Prefix(_prefixConfig, "DEV", "iphone");

            Assert.IsTrue(p1.CompareTo(p2) > 0);
            Assert.IsTrue(p1.CompareTo(p3) > 0);
            Assert.IsTrue(p2.CompareTo(p3) > 0);
            Assert.AreNotEqual(p1, p2);
            Assert.AreEqual(p1, p4);
        }
Beispiel #2
0
        public int CompareTo(ZNodeName other)
        {
            int answer = Prefix.CompareTo(other.Prefix);

            if (answer == 0)
            {
                int s1 = this.sequence;
                int s2 = other.sequence;
                if (s1 == -1 && s2 == -1)
                {
                    return(Name.CompareTo(other.Name));
                }
                answer = s1 == -1 ? 1 : s2 == -1 ? -1 : s1 - s2;
            }
            return(answer);
        }
Beispiel #3
0
        public void CompareTest()
        {
            var p1 = new Prefix(_prefixConfig, "DEV", "iphone");
            var p2 = new Prefix(_prefixConfig, "DEV");
            var p3 = new Prefix(_prefixConfig, "stageB");
            var p4 = new Prefix(_prefixConfig, "DEV", "iphone");
            var p5 = new Prefix(_prefixConfig, "ios", "iphone");

            var prefixes = new [] {p1, p2, p3, p4, p5};
            var max = prefixes.Max();
            var min = prefixes.Min();

            Assert.AreEqual(max, p1);
            Assert.AreEqual(min, p3);
            Assert.IsTrue(p2.CompareTo(p5) < 0);
        }
        public int CompareTo(object obj)
        {
            RS  rs     = (RS)obj;
            int result = Prefix.CompareTo(rs.Prefix);

            if (result != 0)
            {
                return(result);
            }
            result = Number.CompareTo(rs.Number);
            if (result != null)
            {
                return(result);
            }
            return(Suffix.CompareTo(rs.Suffix));
        }
Beispiel #5
0
        public int CompareTo(ITaxonRank other)
        {
            if (Type != TaxonRankType.Custom && other.Type != TaxonRankType.Custom)
            {
                // The order of the values in the enum corresponds to their hierarchical order.

                return(Type.CompareTo(other.Type));
            }
            else if (Suffix == other.Suffix)
            {
                // For custom ranks, we need to infer the hierarchical order based on the name of the rank.
                // This requires that both rank suffixes are "known". If they're not, we can't compare them.

                return(Prefix.CompareTo(other.Prefix));
            }
            else
            {
                // The comparison could not be performed.
                return(0);
            }
        }
Beispiel #6
0
 public int CompareTo(TagRecord other)
 {
     return(Prefix.CompareTo(other.Prefix));
 }
Beispiel #7
0
        public void TestPrefixComparison()
        {
            // Object setup
            object obj1 = new object();
            Prefix p1 = new Prefix();
            Prefix p2 = new Prefix();
            Prefix p3 = new Prefix("Hello", "World", "Foobar");
            Prefix p4 = new Prefix("Hello", "World", "Foobar");
            Prefix p5 = new Prefix("Hello");

            try
            {
                p1.CompareTo(obj1);
                Assert.Fail("Comparison with a non Prefix object should throw ArgumentException");
            }
            catch (ArgumentException)
            {
                // Expected exception
            }

            // Equal
            Assert.AreEqual(0, p1.CompareTo(p2));
            Assert.AreEqual(0, p2.CompareTo(p1));
            Assert.AreEqual(0, p3.CompareTo(p4));
            Assert.AreEqual(0, p4.CompareTo(p3));

            // Not equal
            Assert.IsTrue(0 > p1.CompareTo(p3));
            Assert.IsTrue(0 < p3.CompareTo(p1));
            Assert.IsTrue(0 > p2.CompareTo(p4));
            Assert.IsTrue(0 < p4.CompareTo(p2));
            Assert.IsTrue(0 < p4.CompareTo(p5));
            Assert.IsTrue(0 > p5.CompareTo(p4));
        }