public void testEquals()
        {
            ValueComparablePair <string, int> pair = new ValueComparablePair <string, int>("a", 1);
            ValueComparablePair <string, int> pairWithSameKeyAndValue = new ValueComparablePair <string, int>("a", 1);

            Assert.AreEqual(pair, pairWithSameKeyAndValue);
        }
        public void testCompareToSame()
        {
            ValueComparablePair <string, int> pair         = new ValueComparablePair <string, int>("a", 1);
            ValueComparablePair <string, int> pairWithSame = new ValueComparablePair <string, int>("a", 1);

            Assert.AreEqual(pair.CompareTo(pairWithSame), 0);
        }
        public void testCompareToGreater()
        {
            ValueComparablePair <string, int> pair = new ValueComparablePair <string, int>("a", 1);
            ValueComparablePair <string, int> pairWithGreaterValue = new ValueComparablePair <string, int>("b", 2);

            Assert.AreEqual(pair.CompareTo(pairWithGreaterValue), -1);
        }
        public void testNotEqualsDifferentKeySameValue()
        {
            ValueComparablePair <string, int> pair            = new ValueComparablePair <string, int>("a", 1);
            ValueComparablePair <string, int> pairWithSameKey = new ValueComparablePair <string, int>("b", 1);

            Assert.AreNotEqual(pair, pairWithSameKey);
        }
Exemplo n.º 5
0
        public int CompareTo(ValueComparablePair <K, V> that)
        {
            int res = this.v.CompareTo(that.v);

            if (res == 0)
            {
                return(this.k.CompareTo(that.k));
            }
            return(res);
        }