public static void CollectImpl1a()
        {
            IEnumerable <Either <int, int> > source = new ThrowingEnumerable <Either <int, int> >();

            var q = Assert.DoesNotThrow(() => source.CollectImpl());

            q.OnLeft(x => Assert.ThrowsOnNext(x));
            q.OnRight(x => Assert.Fail());
        }
Exemplo n.º 2
0
        public static void Map1a()
        {
            bool notCalled = true;
            Func <Either <int, int> > fun = () => { notCalled = false; return(Either <int, int> .OfLeft(1)); };
            var q = Either.Map(Enumerable.Repeat(fun, 1), f => f());

            Assert.True(notCalled);
            q.OnLeft(x => Assert.CalledOnNext(x, ref notCalled));
            q.OnRight(x => Assert.Fail());
        }
        public static void WhereImpl1a()
        {
            bool notCalled = true;
            Func <Either <bool, int> > fun
                = () => { notCalled = false; return(Either <bool, int> .OfLeft(true)); };
            var q = Enumerable.Repeat(fun, 1).WhereImpl(f => f());

            Assert.True(notCalled);
            q.OnLeft(x => Assert.CalledOnNext(x, ref notCalled));
            q.OnRight(x => Assert.Fail());
        }
Exemplo n.º 4
0
        public static void Zip1a()
        {
            IEnumerable <int> first = new ThrowingEnumerable <int>();
            var second = Enumerable.Range(0, 1);
            Func <int, int, Either <int, int> > resultSelector = (i, j) => Either <int, int> .OfLeft(i + j);

            var q = Assert.DoesNotThrow(() => Either.Zip(first, second, resultSelector));

            q.OnLeft(x => Assert.ThrowsOnNext(x));
            q.OnRight(x => Assert.Fail());
        }