예제 #1
0
파일: Linq.cs 프로젝트: wee2tee/SoImporter
        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);
        }
예제 #2
0
파일: Linq.cs 프로젝트: wee2tee/SoImporter
        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);
        }
예제 #3
0
파일: Linq.cs 프로젝트: wee2tee/SoImporter
        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);
        }
예제 #4
0
파일: Linq.cs 프로젝트: wee2tee/SoImporter
        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);
        }