Esempio n. 1
0
        public void ExceptionThrownFromFirstsEnumerator()
        {
            MyIEnum <int>        first    = new MyIEnum <int>(new int[] { 1, 3, 3 });
            IEnumerable <int>    second   = new int[] { 2, 4, 6 };
            Func <int, int, int> func     = (x, y) => x + y;
            IEnumerable <int>    expected = new int[] { 3, 7, 9 };

            Assert.Equal(expected, first.Zip(second, func));

            first = new MyIEnum <int>(new int[] { 1, 2, 3 });

            var zip = first.Zip(second, func);

            Assert.Throws <Exception>(() => zip.ToList());
        }
Esempio n. 2
0
            // exception thrown out from second.GetEnumerator
            public static int Test6()
            {
                MyIEnum <int>        second   = new MyIEnum <int>(new int[] { 1, 3, 3 });
                IEnumerable <int>    first    = new int[] { 2, 4, 6 };
                Func <int, int, int> func     = (x, y) => x + y;
                IEnumerable <int>    expected = new int[] { 3, 7, 9 };

                try
                {
                    var actual = first.Zip(second, func);
                    actual.ToList();        // No exception

                    if (Verification.Allequal(expected, actual) != 0)
                    {
                        return(1);
                    }
                }

                catch (Exception)
                {
                    return(1);
                }

                second = new MyIEnum <int>(new int[] { 1, 2, 3 });

                try
                {
                    var actual = first.Zip(second, func);
                    actual.ToList();        // exception

                    return(1);
                }

                catch (Exception)
                {
                    return(0);
                }
            }