예제 #1
0
        public void TestToArray()
        {
            var e    = CountTo100(Thread.CurrentThread);
            var iter = TaskEnumerator <int> .FromEnumerable(e, 1);

            int[] items = (int[])Scheduler.WaitFor(iter.GetArray());

            int[] expected = new int[100];
            for (int i = 0; i < 100; i++)
            {
                expected[i] = i;
            }

            Assert.AreEqual(expected, items);
        }
예제 #2
0
        public void YieldStartGetTaskIterator()
        {
            var e    = CountTo100(Thread.CurrentThread);
            var iter = TaskEnumerator <int> .FromEnumerable(e, 1);

            var output = new List <int>();
            var f      = Scheduler.Start(IterationTask(iter, output));

            Scheduler.WaitFor(f);

            int[] expected = new int[100];
            for (int i = 0; i < 100; i++)
            {
                expected[i] = i;
            }

            Assert.AreEqual(output.ToArray(), expected);
        }