Beispiel #1
0
        public void ReturnsTrueForClassWithValueType()
        {
            object target = new OtherValueType();
            var    result = Testers.CheckNullInequality(target);

            Assert.True(result);
        }
Beispiel #2
0
        public void ReturnsTrueForClassWithStructuralEquality()
        {
            object target = new OtherClassWithEquality();
            var    result = Testers.CheckNullInequality(target);

            Assert.True(result);
        }
Beispiel #3
0
        public void ReturnsTrueForDefaultClass()
        {
            object target = new AnotherClass();
            var    result = Testers.CheckNullInequality(target);

            Assert.True(result);
        }
Beispiel #4
0
        private static bool TestEmptyTypes(Func <object> constructor)
        {
            var a = constructor();
            var b = constructor();

            var correctNullEquality = Testers.CheckNullInequality(a);
            var correctEquality     = Testers.CheckEquality(a, b);
            var commutativeEquality = Testers.CheckEquality(b, a);

            return(correctNullEquality &&
                   correctEquality &&
                   commutativeEquality);
        }
Beispiel #5
0
        private static bool TestPopulatedTypes(Type t, IDictionary <Type, Func <object> > constructors)
        {
            var ctor = constructors[t];
            var a    = ctor();
            var b    = ctor();
            var c    = ctor();

            var equalMembers = new[] { a, b, c };

            var tType = a.GetType();

            var(propertyValues, fieldValues) = Creator.GetPropertyAndFieldValues(tType, constructors);

            var memberUnequalItems = SetupEqualityChecksBasedOnProperties(propertyValues, equalMembers, ctor, fieldValues);
            var badFields          = SetupEqualityChecksBasedOnFields(fieldValues, equalMembers, ctor, propertyValues);

            memberUnequalItems.AddRange(badFields);

            var empty = ctor();

            var emptyInequality = Testers.CheckInequality(a, empty);

            var bEquality            = Testers.CheckEquality(a, b);
            var bCommutativeEquality = Testers.CheckEquality(b, a);

            var cEquality           = Testers.CheckEquality(a, c);
            var associativeEquality = Testers.CheckEquality(b, c);

            var memberInequality = Testers.CheckInequality(memberUnequalItems, a);

            var nullInequality = Testers.CheckNullInequality(a);
            var selfEquality   = Testers.CheckEquality(a, a);

            var typeInequality = Testers.CheckTypeInequality(tType, a);

            return
                (nullInequality &&
                 emptyInequality &&
                 bEquality &&
                 bCommutativeEquality &&
                 cEquality &&
                 associativeEquality &&
                 memberInequality &&
                 selfEquality &&
                 typeInequality);
        }
Beispiel #6
0
        public void ReturnsFalseForNull()
        {
            var result = Testers.CheckNullInequality(null);

            Assert.False(result);
        }