当前位置: 首页>>代码示例>>C#>>正文


C# QueriableDummy类代码示例

本文整理汇总了C#中QueriableDummy的典型用法代码示例。如果您正苦于以下问题:C# QueriableDummy类的具体用法?C# QueriableDummy怎么用?C# QueriableDummy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueriableDummy类属于命名空间,在下文中一共展示了QueriableDummy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestMaxVariableDeclaredCorrectly

        public void TestMaxVariableDeclaredCorrectly()
        {
            var q = new QueriableDummy<ntup2>();

            var result = from evt in q
                         where (from r in evt.run select r).Max() > 10
                         select evt;
            var c = result.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
            var res = DummyQueryExectuor.FinalResult;
            res.DumpCodeToConsole();

            //
            // Code body should have the init for the for loop boundary for loop generated by the (fromxxx) up there and the
            // if statement that tests for > 10.
            // 

            Assert.AreEqual(1, res.Functions.Count(), "# of functions");
            var code = res.Functions.First().StatementBlock;
            var minmax = code.FindStatement<StatementMinMaxTest>();
            Assert.IsNotNull(minmax, "Unable to find the minmax statements");
            var mmaxVar = minmax.MaxMinVariable;
            var declstatement = code.FindDeclarationStatement(mmaxVar);
            Assert.IsNotNull(declstatement, string.Format("Unable to find where {0} for minmax was declared!", mmaxVar.ToString()));
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:26,代码来源:ROMinMaxTest.cs

示例2: TestWhere

        public void TestWhere()
        {
            var q = new QueriableDummy<ntup>();
            var r = from d in q
                    where d.run > 10
                    select d;
            var c = r.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
            var res = DummyQueryExectuor.FinalResult;

            res.DumpCodeToConsole();

            ///
            /// We expect a single top level statement
            /// 

            Assert.AreEqual(1, res.CodeBody.Statements.Count(), "only single statement expected");
            var ifStatement = res.CodeBody.Statements.First() as StatementFilter;
            Assert.IsNotNull(ifStatement, "if statement isn't an if statement!");
            Assert.AreEqual("((*this).run)>10", ifStatement.TestExpression.RawValue, "incorrect if statement");

            ///
            /// Finally, the count statement should be down here!
            /// 

            Assert.AreEqual(1, ifStatement.Statements.Count(), "expected a single statement inside the if statemenet!");
            Assert.IsInstanceOfType(ifStatement.Statements.First(), typeof(StatementAggregate), "incorrect if statement");
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:29,代码来源:TestQueriesTopLevel.cs

示例3: TestDeltaR2

        public void TestDeltaR2()
        {
            var rootFile = TestUtils.CreateFileOfInt(10);

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");

            ///
            /// Get a simple query we can "play" with
            /// 

            var q = new QueriableDummy<LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe>();
            var listing = from evt in q
                          let tlz = ROOTUtils.CreateTLZ(evt.run * 2.2, 1.0, 0.0)
                          where tlz.DeltaR2(tlz) < 1.0
                          select evt;
            var dude = listing.Count();
            var query = DummyQueryExectuor.LastQueryModel;

            ///
            /// Ok, now we can actually see if we can make it "go".
            /// 

            ntuple._gProxyFile = proxyFile.FullName;
            var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe));
            int result = exe.ExecuteScalar<int>(query);
            Assert.AreEqual(10, result);
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:31,代码来源:t_ROOTUtils.cs

示例4: TestBasicUniqueCombo

        public void TestBasicUniqueCombo()
        {
            var q = new QueriableDummy<ntupArray>();
            var results = from evt in q
                          select evt.run.UniqueCombinations().Count();
            var total = results.Aggregate(0, (seed, val) => seed + val);
            //var total = results.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "expecing some code to have been generated");
            DummyQueryExectuor.FinalResult.DumpCodeToConsole();

            var code = DummyQueryExectuor.FinalResult.CodeBody as IBookingStatementBlock;
            Assert.AreEqual(1, code.Statements.Count(), "# fo statements");

            Assert.AreEqual(1, DummyQueryExectuor.FinalResult.Functions.Count(), "# of functiosn");
            code = DummyQueryExectuor.FinalResult.Functions.First().StatementBlock as IBookingStatementBlock;
            var innerloop = code.Statements.Skip(2).First() as IBookingStatementBlock;
            Assert.IsNotNull(innerloop, "inner loop");

            Assert.AreEqual(1, innerloop.Statements.Count(), "# of statements in the inner loop - the push statement");

            var last = code.Statements.Skip(3).First();
            Assert.IsInstanceOfType(last, typeof(LINQToTTreeLib.Statements.StatementPairLoop), "last statement incorrect");

            var res = DummyQueryExectuor.FinalResult.ResultValue;
            Assert.IsNotNull(res, "final result");
            Assert.AreEqual(typeof(int), res.Type, "final result type");

        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:29,代码来源:ROUniqueCombinationsTest.cs

示例5: TestSimpleLoopCombine

        public void TestSimpleLoopCombine()
        {
            var q = new QueriableDummy<LocalNtup>();
            var dudeQ1 = from evt in q
                         from l in evt.myvectorofint
                         select l;
            var dude1 = dudeQ1.Count();

            var gc1 = DummyQueryExectuor.FinalResult;

            var dudeQ2 = from evt in q
                         from l in evt.myvectorofint
                         select l;
            var dude2 = dudeQ2.Count();

            var gc2 = DummyQueryExectuor.FinalResult;

            // Combine them!

            Assert.IsTrue(gc1.CodeBody.TryCombineStatement(gc2.CodeBody, null), "Unable to do combine!");

            gc1.DumpCodeToConsole();

            Assert.AreEqual(1, gc1.CodeBody.Statements.Count(), "# of statements at top level");
            var booking = gc1.CodeBody.Statements.First() as IBookingStatementBlock;
            Assert.AreEqual(2, booking.Statements.Count(), "# of statements in inside loop");
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:27,代码来源:StatementVectorLoopTest.cs

示例6: PrettyPrintSimpleQuery

        public void PrettyPrintSimpleQuery()
        {
            var q = new QueriableDummy<ntup>();

            var r = q.Select(rq => rq.run * 2).PrettyPrintQuery();
            Console.WriteLine(r);
            Assert.IsTrue(r.Contains("select"));
            Assert.IsTrue(r.Contains("[rq].run * 2"));
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:9,代码来源:HelpersTest.cs

示例7: PrettyPrintHideTuples

        public void PrettyPrintHideTuples()
        {
            var q = new QueriableDummy<ntup>();

            var r = q.Select(rq => Tuple.Create(rq.run * 2, 1)).Select(rq => rq.Item1).PrettyPrintQuery();
            Console.WriteLine(r);
            Assert.IsFalse(r.Contains("Tuple"));
            Assert.IsTrue(r.Contains("[rq].run * 2"));

        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:10,代码来源:HelpersTest.cs

示例8: TestSimpleCountReturn

 public void TestSimpleCountReturn()
 {
     var q = new QueriableDummy<ntup2>();
     var result = q.Count();
     Assert.IsNotNull(DummyQueryExectuor.FinalResult, "final result");
     var r = DummyQueryExectuor.FinalResult.ResultValue;
     Assert.AreEqual(typeof(int), r.Type, "result type");
     Assert.AreEqual(DeclarableParameter.ExpressionType, r.NodeType, "Expression type incorrect");
     var dv = r as DeclarableParameter;
     Assert.IsTrue(dv.InitialValue == null || dv.InitialValue.RawValue == "0", "Initial value incorrect");
 }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:11,代码来源:ROCountTest.cs

示例9: TestBasicUniqueCombo

        public void TestBasicUniqueCombo()
        {
            var q = new QueriableDummy<ntupArray>();
            var results = from evt in q
                          select evt.run.PairWiseAll((r1, r2) => r1 != r2).Count();
            var total = results.Aggregate(0, (seed, val) => seed + val);
            //var total = results.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "expecing some code to have been generated");
            DummyQueryExectuor.FinalResult.DumpCodeToConsole();
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:11,代码来源:t_ROPairWiseAll.cs

示例10: TestMaxOfSimpleSequence

 public void TestMaxOfSimpleSequence()
 {
     /// You can't run a query at the top level
     /// The reason is techincal: have to add the infrastructure to save a bool var in the
     /// class instance w/out transfering it back out. Simple, but more work than really
     /// need right now.
     var q = new QueriableDummy<ntup>();
     var result = from d in q
                  select d.run;
     var c = result.Max();
 }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:11,代码来源:ROMinMaxTest.cs

示例11: PrettyPrintComplexQueryII

        public void PrettyPrintComplexQueryII()
        {
            var q = new QueriableDummy<dummyntup>();

            var r = from e in q
                    let rf = (from s in e.valC1D where s > 22 select s * 2).Sum()
                    where rf > 20
                    select e.run;

            var sr = r.PrettyPrintQuery();
            Console.WriteLine(sr);
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:12,代码来源:HelpersTest.cs

示例12: TestSimpleLoopAndFilterCombine

        public void TestSimpleLoopAndFilterCombine()
        {
            const int numberOfIter = 25;
            var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter);

            ///
            /// Generate a proxy .h file that we can use
            /// 

            var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude");

            ///
            /// Get a simple query we can "play" with. That this works
            /// depends on each event having 10 entries in the array, which contains
            /// the numbers 0-10.
            /// 

            var q = new QueriableDummy<TestUtils.TestNtupeArr>();
            var dudeQ1 = from evt in q
                         where (evt.myvectorofint.Max() > 5)
                         select evt;
            var dude1 = dudeQ1.Count();
            var query1 = DummyQueryExectuor.LastQueryModel;

            var dudeQ2 = from evt in q
                         where (evt.myvectorofint.Max() > 5)
                         select evt;
            var dude2 = dudeQ2.Count();
            var query2 = DummyQueryExectuor.LastQueryModel;

            //
            // Convert to future's
            //

            ntuple._gProxyFile = proxyFile.FullName;
            var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestUtils.TestNtupeArr));
            var q1future = exe.ExecuteScalarAsFuture<int>(query1);
            var q2future = exe.ExecuteScalarAsFuture<int>(query2);

            //
            // Run them!
            //

            exe.ExecuteQueuedQueries();

            //
            // And check
            //

            Assert.AreEqual(q1future.Value, numberOfIter);
            Assert.AreEqual(q2future.Value, numberOfIter);
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:52,代码来源:TTreeExecutorCombinationTests.cs

示例13: PrettyPrintComplexQueryI

        public void PrettyPrintComplexQueryI()
        {
            var q = new QueriableDummy<dummyntup>();

            var r = from e in q
                    from s in e.valC1D
                    where s > 22
                    select s * 2;

            var sr = r.PrettyPrintQuery();
            Console.WriteLine(sr);
            Assert.AreEqual(4, CountLines(sr));
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:13,代码来源:HelpersTest.cs

示例14: TestBasicCount

        public void TestBasicCount()
        {
            var q = new QueriableDummy<ntup>();
            var result = from d in q
                         select d;
            var c = result.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
            var res = DummyQueryExectuor.FinalResult;

            /// Return type is correct
            Assert.IsNotNull(res.ResultValue, "Expected a result from the count!");
            Assert.AreEqual(res.ResultValue.Type, typeof(int), "integer return type expected");
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:14,代码来源:TestCount.cs

示例15: TestQueryWithTwoRangeVariablesNamedSameThing

        public void TestQueryWithTwoRangeVariablesNamedSameThing()
        {
            var q = new QueriableDummy<ntup>();
            var result1 = from evt in q
                          where evt.run > 5
                          select evt;
            var result2 = from evt in result1
                          where evt.run > 10
                          select evt;
            var c = result2.Count();

            Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
            DummyQueryExectuor.FinalResult.DumpCodeToConsole();

            /// Looking for an infinite loop!
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:16,代码来源:TestQueriesTopLevel.cs


注:本文中的QueriableDummy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。