public bool IsMatch(FailedAssertion failedAssertion) { var expression = failedAssertion.Expression; return((EqualityPattern.IsEqualityComparison(expression) || LessThanOrGreaterThanPattern.IsNumericalComparison(expression)) && expression is BinaryExpression binaryExpression && IsLengthAccess(binaryExpression.Left)); }
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()}."); }
public bool IsMatch(FailedAssertion failedAssertion) { return(failedAssertion.Expression.NodeType == ExpressionType.Equal || EqualityPattern.EqualsMethodShouldBeTrue(failedAssertion.Expression)); }
public bool IsMatch(FailedAssertion failedAssertion) { return(EqualityPattern.IsEqualityComparison(failedAssertion.Expression) || LessThanOrGreaterThanPattern.IsNumericalComparison(failedAssertion.Expression)); }