public void Int32ComparerTest()
        {
            int o1 = 1;
            int o2 = 2;
            AdvancedComparer <int> comparer = AdvancedComparer <int> .Default;

            Assert.IsNotNull(comparer);
            Assert.AreEqual("Int32Comparer", comparer.Implementation.GetType().Name);
            Assert.Greater(comparer.Compare(o2, o1), 0);
            Assert.IsTrue(comparer.ValueRangeInfo.HasMinValue);
            Assert.IsTrue(comparer.ValueRangeInfo.HasMaxValue);
            Assert.AreEqual(int.MinValue, comparer.ValueRangeInfo.MinValue);
            Assert.AreEqual(int.MaxValue, comparer.ValueRangeInfo.MaxValue);
            Assert.AreEqual(1, comparer.ValueRangeInfo.DeltaValue);
            Assert.AreEqual(1, comparer.GetNearestValue(0, Direction.Positive));
            Assert.AreEqual(0, comparer.GetNearestValue(1, Direction.Negative));
        }
        public void EnumComparerTest()
        {
            AdvancedComparer <Direction> comparer = AdvancedComparer <Direction> .System;

            Assert.IsNotNull(comparer);
            Assert.AreEqual("EnumComparer`2", comparer.Implementation.GetType().Name);
            Assert.Greater(comparer.Compare(Direction.Positive, Direction.Negative), 0);
            Assert.Greater(comparer.Compare(Direction.Positive, Direction.None), 0);
            Assert.Less(comparer.Compare(Direction.Negative, Direction.Positive), 0);
            Assert.Less(comparer.Compare(Direction.Negative, Direction.None), 0);
            Assert.AreEqual(comparer.Compare(Direction.Positive, Direction.Positive), 0);
            Assert.AreEqual(comparer.Compare(Direction.None, Direction.None), 0);
            Assert.AreEqual(comparer.Compare(Direction.Negative, Direction.Negative), 0);

            Assert.IsTrue(comparer.Equals(comparer.ValueRangeInfo.MaxValue, Direction.Positive));
            Assert.IsTrue(comparer.Equals(comparer.ValueRangeInfo.MinValue, Direction.Negative));
            Assert.IsFalse(comparer.Equals(Direction.Positive, Direction.Negative));

            Assert.AreEqual(comparer.GetNearestValue(Direction.Negative, Direction.Negative), Direction.Negative);
            Assert.AreEqual(comparer.GetNearestValue(Direction.Negative, Direction.Positive), Direction.None);
            Assert.AreEqual(comparer.GetNearestValue(Direction.Positive, Direction.Negative), Direction.None);
            Assert.AreEqual(comparer.GetNearestValue(Direction.Positive, Direction.Positive), Direction.Positive);
            Assert.AreEqual(comparer.GetNearestValue(Direction.None, Direction.Negative), Direction.Negative);
            Assert.AreEqual(comparer.GetNearestValue(Direction.None, Direction.Positive), Direction.Positive);
            Assert.IsFalse(comparer.ValueRangeInfo.HasDeltaValue);
        }
        public void StringComparerTest()
        {
            string o1 = "1";
            string o2 = "2";
            AdvancedComparer <string> comparer = AdvancedComparer <string> .Default;

            Assert.IsNotNull(comparer);
            Assert.AreEqual("StringComparer", comparer.Implementation.GetType().Name);
            Assert.Greater(comparer.Compare(o2, o1), 0);
            Assert.IsTrue(comparer.ValueRangeInfo.HasMinValue);
            Assert.IsFalse(comparer.ValueRangeInfo.HasMaxValue);
            Assert.AreEqual(null, comparer.ValueRangeInfo.MinValue);
            AssertEx.ThrowsInvalidOperationException(delegate { string s = comparer.ValueRangeInfo.MaxValue; });

            char z = char.MaxValue;
            char y = unchecked ((char)(char.MaxValue - 1));
            char a = char.MinValue;

            string str = "BCD";

            str = comparer.GetNearestValue(str, Direction.Negative);
            Assert.AreEqual("BCC" + z, str);
            str = comparer.GetNearestValue(str, Direction.Negative);
            Assert.AreEqual("BCC" + y + z, str);
            str = comparer.GetNearestValue(str, Direction.Negative);
            Assert.AreEqual("BCC" + y + y + z, str);
            str = comparer.GetNearestValue(str, Direction.Positive);
            Assert.AreEqual("BCC" + y + z, str);
            str = comparer.GetNearestValue(str, Direction.Positive);
            Assert.AreEqual("BCC" + z, str);
            str = comparer.GetNearestValue(str, Direction.Positive);
            Assert.AreEqual("BCD", str);
            str = comparer.GetNearestValue(str, Direction.Positive);
            Assert.AreEqual("BCD" + a, str);
            str = comparer.GetNearestValue(str, Direction.Positive);
            Assert.AreEqual("BCD" + a + a, str);
            str = comparer.GetNearestValue(str, Direction.Negative);
            Assert.AreEqual("BCD" + a, str);
            str = comparer.GetNearestValue(str, Direction.Negative);
            Assert.AreEqual("BCD", str);
            Assert.IsNull(comparer.GetNearestValue(null, Direction.Negative));
            Assert.IsNull(comparer.GetNearestValue(string.Empty, Direction.Negative));
            Assert.AreEqual(string.Empty, comparer.GetNearestValue(null, Direction.Positive));
            Assert.AreEqual(char.MaxValue.ToString(), comparer.GetNearestValue(char.MaxValue.ToString(), Direction.Positive));
            AssertEx.Throws <ArgumentOutOfRangeException>(delegate { comparer.GetNearestValue(str, Direction.None); });
        }