Example #1
0
        public bool IsMatch(FailedAssertion failedAssertion)
        {
            var expression = failedAssertion.Expression;

            return((EqualityPattern.IsEqualityComparison(expression) ||
                    LessThanOrGreaterThanPattern.IsNumericalComparison(expression)) &&
                   expression is BinaryExpression binaryExpression &&
                   IsLengthAccess(binaryExpression.Left));
        }
Example #2
0
        public FormattableString TryGetFriendlyMessage(FailedAssertion assertion)
        {
            var left = EqualityPattern.GetLeftSide(assertion.Expression);

            var right = EqualityPattern.GetRightSide(assertion.Expression, left);

            if (right.NodeType == ExpressionType.Convert && right.Type == typeof(object))
            {
                right = ((UnaryExpression)right).Operand;
            }

            if (IsConstantExpression(right))
            {
                return($"Expected {left} to equal {right} but {left} was {left.ToValue()}.");
            }

            return($"Expected {left} to equal {right} but {left} was {left.ToValue()} while {right} was {right.ToValue()}.");
        }
Example #3
0
 public bool IsMatch(FailedAssertion failedAssertion)
 {
     return(failedAssertion.Expression.NodeType == ExpressionType.Equal ||
            EqualityPattern.EqualsMethodShouldBeTrue(failedAssertion.Expression));
 }
Example #4
0
 public bool IsMatch(FailedAssertion failedAssertion)
 {
     return(EqualityPattern.IsEqualityComparison(failedAssertion.Expression) ||
            LessThanOrGreaterThanPattern.IsNumericalComparison(failedAssertion.Expression));
 }