Exemplo n.º 1
0
        public void ThrowInBindProducesErrorMonad()
        {
            var monad = new SafeValueMonad <Int32>(2020)
                        .Bind <Boolean>(val => throw new InvalidOperationException("err"));

            Assert.IsInstanceOf(typeof(ErrorMonad <Boolean>), monad);
        }
Exemplo n.º 2
0
        public void ThrowInBindProducesCorrectErrorMessage()
        {
            var monad = new SafeValueMonad <Int32>(2020)
                        .Bind <Boolean>(val => throw new InvalidOperationException("err"));

            var visitor = new AssertErrorVisitor <Boolean>
            {
                AreEqual      = true,
                ExpectedError = "err"
            };

            monad.Accept(visitor);
        }