internal string Format(QueryModel query)
        {
            string result = FormattingQueryVisitor.Format(query);

            Assert.IsNotNull(result, "null return from query string");
            Assert.AreNotEqual(0, result.Length, "query string length");
            return(result);
            // TODO: add assertions to method FormattingQueryVisitorTest.Format(QueryModel)
        }
        public void TestQuerySimple()
        {
            var q   = MakeQuery(0);
            var str = FormattingQueryVisitor.Format(q);

            Console.WriteLine("The result is {0}", str);
            Console.WriteLine("The normal way reuslt is {0}", q.ToString());
            Assert.IsNotNull(str, "null return");
            Assert.AreNotEqual(0, str.Length, "zero length guy");
        }
        /// <summary>
        /// Do the required formatting for a query.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static string Format(QueryModel query)
        {
            if (query == null)
                return "QueryModel(null)";

            var fmt = new FormattingQueryVisitor();
            fmt.VisitQueryModel(query);

            return fmt._queryAsString.ToString();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Do the required formatting for a query.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static string Format(QueryModel query)
        {
            if (query == null)
            {
                return("QueryModel(null)");
            }

            var fmt = new FormattingQueryVisitor();

            fmt.VisitQueryModel(query);

            return(fmt._queryAsString.ToString());
        }
        public void TestForNestedFrom()
        {
            var q      = new QueriableDummyNoExe <arrayntup>();
            var result = from d in q
                         from e in d.vals
                         select e;
            var r  = result.Count();
            var qm = DummyQueryExectuor.LastQueryModel;

            var str = FormattingQueryVisitor.Format(qm);

            Console.WriteLine("result: {0}", str);
            Assert.IsTrue(str.Contains("vals"), "Missing vals in '" + str + "'.");
        }
        public void TestForWhere()
        {
            var q      = new QueriableDummyNoExe <ntup>();
            var result = from d in q
                         where d.run > 20
                         select d;
            var c  = result.Count();
            var qm = DummyQueryExectuor.LastQueryModel;

            var str = FormattingQueryVisitor.Format(qm);

            Console.WriteLine("result: {0}", str);
            Assert.IsTrue(str.Contains("where"), "Missing select in '" + str + "'.");
        }
        public void FormatFunctionExpression()
        {
            Expression <Func <int[], int> > doit = a => a.First();
            var q      = new QueriableDummy <arrayntup>();
            var result = from evt in q
                         where doit.Invoke(evt.vals) > 10
                         select evt;
            var r  = result.Count();
            var qm = DummyQueryExectuor.LastQueryModel;

            var str = FormattingQueryVisitor.Format(qm);

            Console.WriteLine(str);
            Assert.IsFalse(str.Contains("doit"), "Should not contian function name");
        }