本文整理汇总了C#中QueriableDummy类的典型用法代码示例。如果您正苦于以下问题:C# QueriableDummy类的具体用法?C# QueriableDummy怎么用?C# QueriableDummy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueriableDummy类属于命名空间,在下文中一共展示了QueriableDummy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestPlotFromTemplateWithWeight
public void TestPlotFromTemplateWithWeight()
{
// Create the plot
var p = PlottingUtils.MakePlotterSpec<LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe>(10, 0.0, 10.0, evt => evt.run, "dude", "fork", weight: evt => 0.5);
///
/// Get a simple query we can "play" with
///
var q = new QueriableDummy<LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe>();
var r = q.Plot(p, "fork");
DummyQueryExectuor.FinalResult.DumpCodeToConsole();
Assert.IsTrue(DummyQueryExectuor.FinalResult.CodeBody.CodeItUp().Where(l => l.Contains("Fill(((double)(*this).run),0.5*1.0)")).Any(), "no line contains the proper size call!");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:17,代码来源:t_PlottingUtils.cs
示例17: TestSimpleSum
public void TestSimpleSum()
{
var q = new QueriableDummy<ntup>();
var s = q.Sum(i => i.run);
var result = DummyQueryExectuor.FinalResult;
result.DumpCodeToConsole();
//
// Look for the assignment operator in the loop
//
var toplevel = result.CodeBody.Statements;
var assign = toplevel.First() as LINQToTTreeLib.Statements.StatementAssign;
Assert.IsNotNull(assign, "Assign statement missing");
Assert.IsTrue(assign.Expression.RawValue.Contains("+"), "the plus sign is missing");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:18,代码来源:t_ROSum.cs
示例18: TestResolveSubExpression
public void TestResolveSubExpression()
{
var q = new QueriableDummy<LINQToTTreeLib.QueryVisitorTest.ntupWithObjects>();
var result1 = from evt in q
where (from jet in evt.jets where jet.var1 > 1.0 select jet).Count() == 1
select evt;
var c = result1.Count();
Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
DummyQueryExectuor.FinalResult.DumpCodeToConsole();
// Extract the code and count the number of loops. There should be just one for that "where" sub-expression.
Assert.AreEqual(1, DummyQueryExectuor.FinalResult.Functions.Count(), "# of functions");
var code = DummyQueryExectuor.FinalResult.Functions.First().StatementBlock.Statements;
var loopCount = code.Where(s => s is StatementForLoop).Count();
Assert.AreEqual(1, loopCount, "# of loops incorrect");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:18,代码来源:t_ExpressionResolver.cs
示例19: TestSimpleFirst
public void TestSimpleFirst()
{
var q = new QueriableDummy<ntup2>();
var result = from evt in q
where evt.run.First() > 10
select evt;
var c = result.Count();
Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
var query = DummyQueryExectuor.FinalResult;
query.DumpCodeToConsole();
Assert.AreEqual(1, query.CodeBody.Statements.Count(), "# of statements in the code body");
Assert.AreEqual(1, query.Functions.Count(), "# of functions");
var code = query.Functions.First().StatementBlock;
Assert.IsInstanceOfType(code.Statements.Skip(2).First(), typeof(Statements.StatementForLoop), "Expecting a for loop as the first statement");
Assert.IsInstanceOfType(code.Statements.Skip(3).First(), typeof(Statements.StatementThrowIfTrue), "Expecting a filter statement next from the First statement");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:19,代码来源:ROFirstLastTest.cs
示例20: TestNestedQuery
public void TestNestedQuery()
{
var q = new QueriableDummy<ntup>();
var result = from d in q
from m in d.other
select d;
var c = result.Count();
Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!");
/// Return type is correct
Assert.IsNotNull(DummyQueryExectuor.FinalResult.ResultValue, "Expected a result from the count!");
Assert.AreEqual(DummyQueryExectuor.FinalResult.ResultValue.Type, typeof(int), "integer return type expected");
var res = DummyQueryExectuor.FinalResult;
///
/// We should be booking "d" as a variable that hangs out for a while at the top level
///
Assert.AreEqual(0, res.CodeBody.DeclaredVariables.Count(), "Don't need to book any variables for this");
///
/// Now, take a lok at the statements and make sure that we see them all correctly. This first guy should be the
/// loop statement over the d.other guys.
///
Assert.AreEqual(1, res.CodeBody.Statements.Count(), "Expected a single statement");
Assert.IsInstanceOfType(res.CodeBody.Statements.First(), typeof(IBookingStatementBlock), "loop missing!");
var loop = res.CodeBody.Statements.First() as IBookingStatementBlock;
var firstLine = loop.CodeItUp().First();
///
/// And below that should be one statement that does the incrementing
///
Assert.AreEqual(1, loop.Statements.Count(), "incorrect # of statements");
var statement = loop.Statements.First();
Assert.IsInstanceOfType(statement, typeof(StatementAggregate), "count should be incrementing an integer!");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:42,代码来源:TestQueriesGreaterLevels.cs
注:本文中的QueriableDummy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论