public void op_Compare_ValueObjectOfT_ValueObjectOfT_whenSame()
        {
            var comparand1 = new ComparableObjectDerived("value");
            var comparand2 = comparand1;

            Assert.Equal(0, ComparableObject.Compare(comparand1, comparand2));
        }
        public void op_Compare_ValueObjectOfTLesser_ValueObjectOfT()
        {
            var comparand1 = new ComparableObjectDerived("bar");
            var comparand2 = new ComparableObjectDerived("foo");

            Assert.True(ComparableObject.Compare(comparand1, comparand2) < 0);
        }
示例#3
0
 public static int Compare(ComparableObject comparand1,
                           ComparableObject comparand2)
 {
     return ReferenceEquals(comparand1, comparand2)
                ? 0
                : string.Compare(
                                 ReferenceEquals(null, comparand1) ? null : comparand1.ToString(),
                                 ReferenceEquals(null, comparand2) ? null : comparand2.ToString(),
                                 StringComparison.OrdinalIgnoreCase);
 }
示例#4
0
 public static int Compare(ComparableObject comparand1,
                           ComparableObject comparand2)
 {
     return(ReferenceEquals(comparand1, comparand2)
                ? 0
                : string.Compare(
                ReferenceEquals(null, comparand1) ? null : comparand1.ToString(),
                ReferenceEquals(null, comparand2) ? null : comparand2.ToString(),
                StringComparison.OrdinalIgnoreCase));
 }
        public void op_Compare_ValueObjectOfT_ValueObjectOfTNull()
        {
            var comparand1 = new ComparableObjectDerived("value");

            Assert.True(ComparableObject.Compare(comparand1, null) > 0);
        }
        public void op_Compare_ValueObjectOfTNull_ValueObjectOfT()
        {
            var comparand2 = new ComparableObjectDerived("value");

            Assert.True(ComparableObject.Compare(null, comparand2) < 0);
        }