Пример #1
0
        public void TestSimpleAddition()
        {
            MEFUtilities.Compose(new TypeHandlers.TypeHandlerCache());
            AggregateFromSeedResultOperator agg = new AggregateFromSeedResultOperator(Expression.Constant(1),
                                                                                      Expression.Lambda(Expression.MakeBinary(ExpressionType.Add, Expression.Parameter(typeof(int), "count"), Expression.Constant(1)),
                                                                                                        Expression.Parameter(typeof(int), "count")),
                                                                                      null);

            ROAggregate   processor = new ROAggregate();
            GeneratedCode gc        = new GeneratedCode();
            var           result    = ProcessResultOperator(processor, agg, null, gc);

            Assert.AreEqual(typeof(int), result.Type, "Expected the type to be an integer!");

            Assert.IsInstanceOfType(result, typeof(DeclarableParameter), "Expected a var simple!");
            var vs = result as DeclarableParameter;

            Assert.AreEqual("1", vs.InitialValue.RawValue, "Incorrect seed value");

            ///
            /// Now make sure the statements came back ok!
            ///

            gc.DumpCodeToConsole();
            Assert.AreEqual(0, gc.CodeBody.DeclaredVariables.Count(), "Expected no bookings");
            Assert.AreEqual(1, gc.CodeBody.Statements.Count(), "expected a statement!");
            Assert.IsInstanceOfType(gc.CodeBody.Statements.First(), typeof(Statements.StatementAggregate), "expected an assignment statement!");

            var           ass = gc.CodeBody.Statements.First() as Statements.StatementAggregate;
            StringBuilder bld = new StringBuilder();

            bld.AppendFormat("{0}+1", ass.ResultVariable.ParameterName);
            Assert.AreEqual(bld.ToString(), ass.Expression.RawValue, "the raw value of hte expression is not right");
        }
Пример #2
0
        public bool CanHandle([PexAssumeUnderTest] ROAggregate target, Type resultOperatorType)
        {
            bool result = target.CanHandle(resultOperatorType);

            return(result);
            // TODO: add assertions to method ROAggregateTest.CanHandle(ROAggregate, Type)
        }
Пример #3
0
        public void TestWithAgPostSelector()
        {
            Expression <Func <int, int> >   selector = cnt => cnt * 2;
            AggregateFromSeedResultOperator agg      = new AggregateFromSeedResultOperator(Expression.Constant(1),
                                                                                           Expression.Lambda(Expression.MakeBinary(ExpressionType.Add, Expression.Parameter(typeof(int), "count"), Expression.Constant(1)),
                                                                                                             Expression.Parameter(typeof(int), "count")),
                                                                                           selector);

            ROAggregate   processor = new ROAggregate();
            GeneratedCode gc        = new GeneratedCode();
            var           result    = ProcessResultOperator(processor, agg, null, gc);
        }
Пример #4
0
        /// Pex seems to hang when it tries to explore this one.
        ///[PexMethod]
        public Expression ProcessResultOperator(
            ROAggregate target,
            ResultOperatorBase resultOperator,
            QueryModel queryModel,
            IGeneratedQueryCode _codeEnv
            )
        {
            CodeContext c = new CodeContext();
            Expression  result
                = target.ProcessResultOperator(resultOperator, queryModel, _codeEnv, c, MEFUtilities.MEFContainer);

            return(result);
            // TODO: add assertions to method ROAggregateTest.ProcessResultOperator(ROAggregate, ResultOperatorBase, QueryModel, IGeneratedCode)
        }