Represents 'is not null' in a comparison.
Наследование: Remotion.Linq.Clauses.Expressions.ExtensionExpression
    public Expression SplitPotentialCompoundComparison (SqlIsNotNullExpression potentialCompoundComparison)
    {
      ArgumentUtility.CheckNotNull ("potentialCompoundComparison", potentialCompoundComparison);

      var innerExpressionAsNewExpression = potentialCompoundComparison.Expression as NewExpression;
      if (innerExpressionAsNewExpression != null)
      {
        if (innerExpressionAsNewExpression.Arguments.Count == 0)
          return Expression.Constant (true);

        return innerExpressionAsNewExpression.Arguments
            .Select (arg => (Expression) new SqlIsNotNullExpression (arg))
            .Aggregate (Expression.OrElse);
      }

      return potentialCompoundComparison;
    }
    public SqlIsNotNullExpression ResolvePotentialEntityComparison (SqlIsNotNullExpression isNotNullExpression)
    {
      var newExpression = ResolvePotentialEntity (isNotNullExpression.Expression);

      if (newExpression != isNotNullExpression.Expression)
        return new SqlIsNotNullExpression (newExpression);

      return isNotNullExpression;
    }
    public Expression VisitSqlIsNotNullExpression (SqlIsNotNullExpression expression)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);

      var baseVisitedExpression = (SqlIsNotNullExpression) base.VisitExtensionExpression (expression);

      var expressionWithEntityComparisonResolved = _entityIdentityResolver.ResolvePotentialEntityComparison (baseVisitedExpression);
      var result = _compoundComparisonSplitter.SplitPotentialCompoundComparison (expressionWithEntityComparisonResolved);

      if (baseVisitedExpression != result)
        return VisitExpression (result);

      return baseVisitedExpression;
    }
    public void SplitPotentialCompoundComparison_SqlIsNotNullExpression_ExpandsNewExpression_ByCheckingAllArguments_ZeroArguments ()
    {
      var newExpression = Expression.New (TypeForNewExpression.GetConstructor ());
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (newExpression);

      var result = _compoundExpressionComparisonSplitter.SplitPotentialCompoundComparison (sqlIsNotNullExpression);

      var expected = Expression.Constant (true);
      SqlExpressionTreeComparer.CheckAreEqualTrees (expected, result);
    }
    public void SplitPotentialCompoundComparison_SqlIsNotNullExpression_ExpandsNewExpression_ByCheckingAllArguments_OnlyOneArgument ()
    {
      var arg1 = Expression.Constant (1);
      var newExpression = Expression.New (TypeForNewExpression.GetConstructor (typeof (int)), new[] { arg1 });
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (newExpression);

      var result = _compoundExpressionComparisonSplitter.SplitPotentialCompoundComparison (sqlIsNotNullExpression);

      var expected = new SqlIsNotNullExpression (arg1);
      SqlExpressionTreeComparer.CheckAreEqualTrees (expected, result);
    }
    public void SplitPotentialCompoundComparison_SqlIsNotNullExpression_ReturnsNonNewExpression_Unchanged ()
    {
      var expression = Expression.Constant (1);
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (expression);

      var result = _compoundExpressionComparisonSplitter.SplitPotentialCompoundComparison (sqlIsNotNullExpression);

      Assert.That (result, Is.SameAs (sqlIsNotNullExpression));
    }
    public Expression VisitSqlIsNotNullExpression (SqlIsNotNullExpression expression)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);

      var newExpression = ApplySingleValueContext (expression.Expression);
      if (newExpression != expression.Expression)
        return new SqlIsNotNullExpression (newExpression);
      return expression;
    }
    public void VisitSqlIsNotNullExpression_RevisitingTerminatesAfterInnerChanges_WithoutOuterChanges  ()
    {
      var inner = Expression.Constant (0);
      var isNotNullExpression = new SqlIsNotNullExpression (inner);

      var fakeResolvedInner = new SqlLiteralExpression (1);
      _resolverMock.Expect (mock => mock.ResolveConstantExpression (inner)).Return (fakeResolvedInner);

      _entityIdentityResolverMock
          .Expect (mock => mock.ResolvePotentialEntityComparison (Arg<SqlIsNotNullExpression>.Is.Anything))
          .Return (null)
          .WhenCalled (mi => mi.ReturnValue = mi.Arguments[0]);
      _compoundComparisonSplitterMock
          .Expect (mock => mock.SplitPotentialCompoundComparison (Arg<SqlIsNotNullExpression>.Is.Anything))
          .Return (null)
          .WhenCalled (mi => mi.ReturnValue = mi.Arguments[0]);


      // No revisiting

      var result = _visitor.VisitExpression (isNotNullExpression);

      _resolverMock.VerifyAllExpectations ();
      _entityIdentityResolverMock.VerifyAllExpectations ();
      _compoundComparisonSplitterMock.VerifyAllExpectations ();

      Assert.That (result, Is.TypeOf<SqlIsNotNullExpression> ());
      Assert.That (((SqlIsNotNullExpression) result).Expression, Is.SameAs (fakeResolvedInner));
    }
    public void VisitSqlIsNotNullExpression ()
    {
      var inner = Expression.Constant (0);
      var isNotNullExpression = new SqlIsNotNullExpression (inner);

      var fakeResolvedInner = new SqlLiteralExpression (1);
      _resolverMock.Expect (mock => mock.ResolveConstantExpression (inner)).Return (fakeResolvedInner);

      var fakeResolvedEntityComparison = new SqlIsNotNullExpression (Expression.Constant (2));
      _entityIdentityResolverMock
          .Expect (mock => mock.ResolvePotentialEntityComparison (Arg<SqlIsNotNullExpression>.Matches (e => e.Expression == fakeResolvedInner)))
          .Return (fakeResolvedEntityComparison);

      var fakeSplitCompoundComparison = new SqlIsNotNullExpression (Expression.Constant (3));
      _compoundComparisonSplitterMock
          .Expect (mock => mock.SplitPotentialCompoundComparison (fakeResolvedEntityComparison))
          .Return (fakeSplitCompoundComparison);

      // Result is revisited
      _resolverMock
          .Expect (mock => mock.ResolveConstantExpression ((ConstantExpression) fakeSplitCompoundComparison.Expression))
          .Return (fakeSplitCompoundComparison.Expression);
      _entityIdentityResolverMock
          .Expect (mock => mock.ResolvePotentialEntityComparison (fakeSplitCompoundComparison))
          .Return (fakeSplitCompoundComparison);
      _compoundComparisonSplitterMock
          .Expect (mock => mock.SplitPotentialCompoundComparison (fakeSplitCompoundComparison))
          .Return (fakeSplitCompoundComparison);

      var result = _visitor.VisitExpression (isNotNullExpression);

      _resolverMock.VerifyAllExpectations ();
      _entityIdentityResolverMock.VerifyAllExpectations ();
      _compoundComparisonSplitterMock.VerifyAllExpectations ();

      Assert.That (result, Is.SameAs (fakeSplitCompoundComparison));
    }
    public void ResolvePotentialEntityComparison_SqlIsNotNullExpression_NonEntities_ReturnsSameExpression ()
    {
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (Expression.Constant (0));

      var result = _entityIdentityResolver.ResolvePotentialEntityComparison (sqlIsNotNullExpression);

      Assert.That (result, Is.SameAs (sqlIsNotNullExpression));
    }
    public void ResolvePotentialEntityComparison_SqlIsNotNullExpression_ResolvesEntitiesToIdentity ()
    {
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (_entityExpression);

      var result = _entityIdentityResolver.ResolvePotentialEntityComparison (sqlIsNotNullExpression);

      var expected = new SqlIsNotNullExpression (_entityExpression.GetIdentityExpression ());
      SqlExpressionTreeComparer.CheckAreEqualTrees (expected, result);
    }
    public void VisitSqlIsNotNullExpression ()
    {
      var expression = Expression.Constant ("test");
      var sqlIsNotNullExpression = new SqlIsNotNullExpression (expression);

      SqlGeneratingExpressionVisitor.GenerateSql (
          sqlIsNotNullExpression, _commandBuilder, _stageMock);

      Assert.That (_commandBuilder.GetCommandText(), Is.EqualTo ("(@1 IS NOT NULL)"));
    }
 public void SetUp ()
 {
   _sqlIsNotNullExpression = new SqlIsNotNullExpression(Expression.Constant(2));
 }
    public void VisitSqlIsNotNullExpression_AppliesSingleValueSemantics_ThrowsForComplexValue ()
    {
      var entityExpression = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression (typeof (Cook));
      var sqlIsNotNullExpressionWithEntity = new SqlIsNotNullExpression (entityExpression);

      Assert.That (() => _valueRequiredVisitor.VisitSqlIsNotNullExpression (sqlIsNotNullExpressionWithEntity), Throws.TypeOf<NotSupportedException> ());
    }
    public void VisitSqlIsNotNullExpression_AppliesSingleValueSemantics_AllowsSingleValue ()
    {
      var sqlIsNotNullExpressionWithValue = new SqlIsNotNullExpression (Expression.Constant (1));

      var resultWithValue = _valueRequiredVisitor.VisitSqlIsNotNullExpression (sqlIsNotNullExpressionWithValue);

      Assert.That (resultWithValue, Is.SameAs (sqlIsNotNullExpressionWithValue));
    }