示例#1
0
        public void Try_CatchesException_ReturnsFaultedResult()
        {
            Result <int, Exception> expected = Err <Exception>(new DivideByZeroException());

            Result <int, Exception> actual = Try(() => TestStubs.Divide(10, 0));

            actual.Should().Be(expected);
        }
示例#2
0
        public void Try_CatchesSpecificException_ReturnsFaultedResult()
        {
            var expected = Err(new DivideByZeroException());

            var actual = Try <int, DivideByZeroException>(() => TestStubs.Divide(10, 0));

            actual.Should().Be(expected);
        }
        public void AndThenTry_TryChain_ReturnsFaultedResult()
        {
            var expected = Err(new DivideByZeroException());

            var actual = Result <int, DivideByZeroException>
                         .Ok(10)
                         .AndThenTry(x => TestStubs.Divide(x, 0));

            actual.Should().Be(expected);
        }