Exemplo n.º 1
0
        public static void FillEqualityErrorMessage(FluentMessage msg, object instance, object expected, bool negated,
                                                    bool usingOperator)
        {
            var operatorText = negated ? "different from" : string.Empty;

            if (negated)
            {
                msg.Expected(expected).Comparison(operatorText).WithType();
                return;
            }

            // shall we display the type as well?
            var withType = instance != null && expected != null && instance.GetType() != expected.GetType() ||
                           instance == null;

            // shall we display the hash too
            var withHash = instance != null && expected != null && instance.GetType() == expected.GetType() &&
                           instance.ToStringProperlyFormatted() == expected.ToStringProperlyFormatted();

            msg.On(instance)
            .WithType(withType)
            .WithHashCode(withHash)
            .And.Expected(expected)
            .WithType(withType)
            .Comparison(operatorText)
            .WithHashCode(withHash);
        }
Exemplo n.º 2
0
        public static void FillEqualityErrorMessage(FluentMessage msg, object instance, object expected, bool negated)
        {
            if (negated)
            {
                msg.Expected(expected).Comparison("different from").WithType();
                return;
            }

            // shall we display the type as well?
            var withType = (instance != null && expected != null && instance.GetType() != expected.GetType()) ||
                           (instance == null);

            // shall we display the hash too
            var withHash = instance != null && expected != null && instance.GetType() == expected.GetType() &&
                           instance.ToString() == expected.ToString();

            msg.On(instance)
            .WithType(withType)
            .WithHashCode(withHash)
            .And.Expected(expected)
            .WithType(withType)
            .WithHashCode(withHash);
            return;
        }