public void HandleResultOperator ()
    {
      _sqlStatementBuilder.SelectProjection = new NamedExpression (null, _sqlStatementBuilder.SelectProjection);
      var countResultOperator = new CountResultOperator ();

      _handler.HandleResultOperator (countResultOperator, _sqlStatementBuilder, _generator, _stageMock, _context);

      Assert.That (((AggregationExpression) _sqlStatementBuilder.SelectProjection).AggregationModifier, Is.EqualTo (AggregationModifier.Count));
      Assert.That (_sqlStatementBuilder.DataInfo, Is.TypeOf (typeof (StreamedScalarValueInfo)));
      Assert.That (((StreamedScalarValueInfo) _sqlStatementBuilder.DataInfo).DataType, Is.EqualTo (typeof (int)));
    }
Esempio n. 2
0
        public void HandleResultOperator()
        {
            _sqlStatementBuilder.SelectProjection = new NamedExpression(null, _sqlStatementBuilder.SelectProjection);
            var countResultOperator = new CountResultOperator();

            _handler.HandleResultOperator(countResultOperator, _sqlStatementBuilder, _generator, _stageMock, _context);

            Assert.That(((AggregationExpression)_sqlStatementBuilder.SelectProjection).AggregationModifier, Is.EqualTo(AggregationModifier.Count));
            Assert.That(_sqlStatementBuilder.DataInfo, Is.TypeOf(typeof(StreamedScalarValueInfo)));
            Assert.That(((StreamedScalarValueInfo)_sqlStatementBuilder.DataInfo).DataType, Is.EqualTo(typeof(int)));
        }
Esempio n. 3
0
 internal Expression ProcessResultOperator(
     [PexAssumeUnderTest]ROCount target,
     CountResultOperator resultOperator,
     QueryModel queryModel,
     GeneratedCode codeEnv
 )
 {
     int origCount = 0;
     if (codeEnv != null)
         origCount = codeEnv.CodeBody.Statements.Count();
     CodeContext c = new CodeContext();
     Expression result = target.ProcessResultOperator(resultOperator, queryModel, codeEnv, c, null);
     Assert.AreEqual(origCount + 1, codeEnv.CodeBody.Statements.Count(), "Expected an added statement!");
     Assert.IsInstanceOfType(codeEnv.CodeBody.Statements.Last(), typeof(StatementAggregate), "Statement to inc the integer must have been done!");
     Assert.AreEqual(result.Type, typeof(int), "Expected to be calculating an integer");
     return result;
 }
        public void SetUp()
        {
            _visitor    = new TestFetchFilteringQueryModelVisitor();
            _queryModel = ExpressionHelper.CreateQueryModel <Cook> ();

            _distinctResultOperator = new DistinctResultOperator();
            _countResultOperator    = new CountResultOperator();

            _fetchOneRequest  = new FetchOneRequest(typeof(Cook).GetProperty("Substitution"));
            _fetchManyRequest = new FetchManyRequest(typeof(Cook).GetProperty("Assistants"));

            _innerFetchManyRequest = new FetchManyRequest(typeof(Cook).GetProperty("Holidays"));
            _fetchOneRequest.GetOrAddInnerFetchRequest(_innerFetchManyRequest);

            _queryModel.ResultOperators.Add(_distinctResultOperator);
            _queryModel.ResultOperators.Add(_fetchOneRequest);
            _queryModel.ResultOperators.Add(_fetchManyRequest);
            _queryModel.ResultOperators.Add(_countResultOperator);
        }
        private void VisitCountResultOperator(CountResultOperator countResultOperator, Remotion.Linq.QueryModel queryModel, int index)
        {
            Call distinct = new Call(MethodNames.Distinct);

            distinct.Arguments.Add(_mainFromComponent.About);
            UnboundConstrain constrain = (UnboundConstrain)_mainFromComponent.Elements.FirstOrDefault(item => item.GetType() == typeof(UnboundConstrain));

            if (constrain != null)
            {
                _mainFromComponent.Elements.Remove(constrain);
            }

            Call count = new Call(MethodNames.Count);

            count.Arguments.Add(distinct);
            _query.Select.Clear();
            Alias alias = new Alias(count, new Identifier(_query.CreateVariableName(_query.RetrieveIdentifier(_mainFromComponent.About.Name) + "Count"), typeof(int)));

            _query.Select.Add(alias);
        }
Esempio n. 6
0
        internal Expression ProcessResultOperator(
            [PexAssumeUnderTest] ROCount target,
            CountResultOperator resultOperator,
            QueryModel queryModel,
            GeneratedCode codeEnv
            )
        {
            int origCount = 0;

            if (codeEnv != null)
            {
                origCount = codeEnv.CodeBody.Statements.Count();
            }
            CodeContext c      = new CodeContext();
            Expression  result = target.ProcessResultOperator(resultOperator, queryModel, codeEnv, c, null);

            Assert.AreEqual(origCount + 1, codeEnv.CodeBody.Statements.Count(), "Expected an added statement!");
            Assert.IsInstanceOfType(codeEnv.CodeBody.Statements.Last(), typeof(StatementAggregate), "Statement to inc the integer must have been done!");
            Assert.AreEqual(result.Type, typeof(int), "Expected to be calculating an integer");
            return(result);
        }
Esempio n. 7
0
 public void SetUp()
 {
     _resultOperator = new CountResultOperator();
 }
 public void SetUp ()
 {
   _resultOperator = new CountResultOperator ();
 }
 private static Expression ProcessResultOperator(Expression expression, Type expressionItemType, CountResultOperator _)
 {
     return(Expression.Call(_countAsyncShim.MakeGenericMethod(expressionItemType), expression));
 }
Esempio n. 10
0
 private static Expression HandleResultOperator(Expression expression, Type expressionItemType, CountResultOperator _)
 {
     return(Expression.Call(_count.MakeGenericMethod(expressionItemType), expression));
 }
 private void HandleCount(SubQueryExpression subquery, CountResultOperator ro) =>
 HandleArrayFunc(subquery, "ARRAY_COUNT()");
 private void VisitCountResultOperator(CountResultOperator countResultOperator, Remotion.Linq.QueryModel queryModel, int index)
 {
     _result = new Call(MethodNames.Count);
 }
 private void VisitCountResultOperator(CountResultOperator countResultOperator, Remotion.Linq.QueryModel queryModel, int index)
 {
     _result = new Call(MethodNames.Count);
 }
        private void VisitCountResultOperator(CountResultOperator countResultOperator, Remotion.Linq.QueryModel queryModel, int index)
        {
            Call distinct = new Call(MethodNames.Distinct);
            distinct.Arguments.Add(_mainFromComponent.About);
            UnboundConstrain constrain = (UnboundConstrain)_mainFromComponent.Elements.FirstOrDefault(item => item.GetType() == typeof(UnboundConstrain));
            if (constrain != null)
            {
                _mainFromComponent.Elements.Remove(constrain);
            }

            Call count = new Call(MethodNames.Count);
            count.Arguments.Add(distinct);
            _query.Select.Clear();
            Alias alias = new Alias(count, new Identifier(_query.CreateVariableName(_query.RetrieveIdentifier(_mainFromComponent.About.Name) + "Count"), typeof(int)));
            _query.Select.Add(alias);
        }