本文整理汇总了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()));
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例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"));
}
示例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"));
}
示例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");
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
示例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");
}
示例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!
}