Ejemplo n.º 1
0
        public void SimpleLinqDynamicLinq()
        {
            var expected = Enumerable.Range(1, 10).Where(i => i > 5).Skip(1).Take(2).Max();
            var actual   = Impromptu.DynamicLinq(Enumerable.Range(1, 10)).Where(new Func <int, bool>(i => i > 5)).Skip(1).Take(2).Max();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void MoreGenericsDynamicLinq()
        {
            var expected = Enumerable.Range(1, 10).Select(i => Tuple.Create(1, i)).Aggregate(0, (accum, each) => each.Item2);
            var actual   = Impromptu.DynamicLinq(Enumerable.Range(1, 10))
                           .Select(new Func <int, Tuple <int, int> >(i => Tuple.Create(1, i)))
                           .Aggregate(0, new Func <int, Tuple <int, int>, int>((accum, each) => each.Item2));

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void PythonDynamicLinqGenericArgs()
        {
            var start    = new Object[] { 1, "string", 4, Guid.Empty, 6 };
            var expected = start.OfType <int>().Skip(1).First();
            var actual   = RunPythonHelper(Impromptu.DynamicLinq(start), @"
import System
result = linq.OfType[System.Int32]().Skip(1).First()

");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void PythonDynamicLinq()
        {
            var expected = Enumerable.Range(1, 10).Where(x => x < 5).OrderBy(x => 10 - x).First();


            var actual = RunPythonHelper(Impromptu.DynamicLinq(Enumerable.Range(1, 10)),
                                         @"
import System
result = linq.Where.Overloads[System.Func[int, bool]](lambda x: x < 5).OrderBy(lambda x: 10-x).First()

");

            Assert.AreEqual(expected, actual);
        }