Exemple #1
0
        public void TryCatchNoExceptionTest()
        {
            bool exception_occured = false;

            Flux.Try(() => { }).Catch <Exception>(ex => { exception_occured = true; });
            Assert.IsFalse(exception_occured);
        }
Exemple #2
0
        public void TryCatchExcutedTest()
        {
            bool exception_occured = false;

            Flux.Try(() => { throw new NotImplementedException(); })
            .Catch <NotImplementedException>(ex => { exception_occured = true; });
            Assert.IsTrue(exception_occured);
        }
Exemple #3
0
        public void Test_Try_4_Catch_CatchExcuted_ByCorrectOrder()
        {
            bool exception_occured = false;

            Flux.Try(() => { throw new NotImplementedException(); })
            .Catch <NotImplementedException, Exception>(ex1 => { exception_occured = true; }, ex2 => { });   // catch more than one

            Assert.IsTrue(exception_occured);
        }
Exemple #4
0
        public void TryCatchTest()
        {
            var result = 0;

            Flux.Try(() =>
            {
                throw new NotImplementedException();
                result = 10;
            }).Catch(exception => { result = 20; });
            Assert.AreEqual(20, result);
        }
Exemple #5
0
        public void TrySwallowIfTest4()
        {
            int result = 0;

            Flux.Try(() =>
            {
                throw new ArithmeticException();
                ++result;
            }).SwallowIf <NullReferenceException, OutOfMemoryException, ArithmeticException, IndexOutOfRangeException>();
            Assert.AreEqual(result, 0);
        }
Exemple #6
0
        public void TrySwallowIfTest2()
        {
            int result = 0;

            Flux.Try(() =>
            {
                throw new NullReferenceException();
                ++result;
            }).SwallowIf <NullReferenceException, ArgumentException>();
            Assert.AreEqual(result, 0);
        }
Exemple #7
0
        public void TrySwallowTest()
        {
            var result = 0;

            Flux.Try(() =>
            {
                throw new NotImplementedException();
                ++result;
            }).Swallow();
            Assert.AreEqual(0, result);
        }
Exemple #8
0
        public void TrySwallowIfUnmatchedTest()
        {
            int result = 0;

            Flux.Try(() =>
            {
                throw new NotImplementedException();
                ++result;
            }).SwallowIf <NullReferenceException>();

            Assert.AreEqual(result, 0);
        }