protected override Expression VisitBinary(BinaryExpression node) { if (node != null && this.stackIndex > 0) { if (node.NodeType != ExpressionType.Equal && node.NodeType != ExpressionType.AndAlso) throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.LinqBinaryOperatorNotSupported, node.ToStringFixed())); if (node.NodeType == ExpressionType.Equal) { // TODO: throw if a matcher is used on either side of the expression. //ThrowIfMatcherIsUsed( // Account for the inverted assignement/querying like "false == foo.IsValid" scenario if (node.Left.NodeType == ExpressionType.Constant) // Invert left & right nodes in this case. return ConvertToSetup(node.Right, node.Left) ?? base.VisitBinary(node); else // Perform straight conversion where the right handside will be the setup return value. return ConvertToSetup(node.Left, node.Right) ?? base.VisitBinary(node); } } return base.VisitBinary(node); }