예제 #1
0
        /// <inheritdoc/>
        public int CompareTo(ComparableTuple <T> other)
        {
            // Compare by Key first, then by Value if that was equal
            int keyCompare = Key.CompareTo(other.Key);

            return((keyCompare == 0) ? Value.CompareTo(other.Value) : keyCompare);
        }
예제 #2
0
        public void TestCompareTo()
        {
            var tuple1 = new ComparableTuple <int>(1, 1);
            var tuple2 = new ComparableTuple <int>(1, 2);
            var tuple3 = new ComparableTuple <int>(2, 1);

            tuple1.Should().Be(tuple1);

            tuple1.Should().BeLessThan(tuple2);
            tuple2.Should().BeLessThan(tuple3);
            tuple3.Should().BeGreaterThan(tuple2);
            tuple2.Should().BeGreaterThan(tuple1);
        }
예제 #3
0
 /// <inheritdoc/>
 public bool Equals(ComparableTuple <T> other) => Equals(Key, other.Key) && Equals(Value, other.Value);