예제 #1
0
        public void SafeExecuteTest5_1()
        {
            var actual =
                ActionEx
                .SafeExecute(() => { },
                             typeof(ArgumentNullException),
                             typeof(ArgumentOutOfRangeException),
                             typeof(InvalidCastException),
                             typeof(InvalidOperationException),
                             typeof(ArithmeticException));

            Assert.True(actual);

            actual =
                ActionEx
                .SafeExecute(() => throw new ArgumentNullException(),
                             typeof(ArgumentNullException),
                             typeof(ArgumentOutOfRangeException),
                             typeof(InvalidCastException),
                             typeof(InvalidOperationException),
                             typeof(ArithmeticException));
            Assert.False(actual);

            actual =
                ActionEx
                .SafeExecute(() => throw new ArgumentOutOfRangeException(),
                             typeof(ArgumentNullException),
                             typeof(ArgumentOutOfRangeException),
                             typeof(InvalidCastException),
                             typeof(InvalidOperationException),
                             typeof(ArithmeticException));
            Assert.False(actual);

            actual =
                ActionEx
                .SafeExecute(() => throw new InvalidCastException(),
                             typeof(ArgumentNullException),
                             typeof(ArgumentOutOfRangeException),
                             typeof(InvalidCastException),
                             typeof(InvalidOperationException),
                             typeof(ArithmeticException));
            Assert.False(actual);

            actual = ActionEx.SafeExecute(() => throw new InvalidOperationException(),
                                          typeof(ArgumentNullException),
                                          typeof(ArgumentOutOfRangeException),
                                          typeof(InvalidCastException),
                                          typeof(InvalidOperationException),
                                          typeof(ArithmeticException));
            Assert.False(actual);

            actual = ActionEx.SafeExecute(() => throw new ArithmeticException(),
                                          typeof(ArgumentNullException),
                                          typeof(ArgumentOutOfRangeException),
                                          typeof(InvalidCastException),
                                          typeof(InvalidOperationException),
                                          typeof(ArithmeticException));
            Assert.False(actual);
        }
예제 #2
0
        public void SafeExecuteTest1_1()
        {
            var actual = ActionEx.SafeExecute <ArgumentNullException>(() => { });

            Assert.True(actual);

            actual = ActionEx.SafeExecute <ArgumentNullException>(() => throw new ArgumentNullException());
            Assert.False(actual);
        }
예제 #3
0
        public void SafeExecuteTest()
        {
            var actual = ActionEx.SafeExecute(() => { });

            Assert.True(actual);

            actual = ActionEx.SafeExecute(() => throw new Exception());
            Assert.False(actual);
        }
예제 #4
0
        public void SafeExecuteTest4_1()
        {
            var actual =
                ActionEx
                .SafeExecute
                <ArgumentNullException, ArgumentOutOfRangeException, InvalidCastException, InvalidOperationException
                >(() => { });

            Assert.True(actual);

            actual =
                ActionEx
                .SafeExecute
                <ArgumentNullException, ArgumentOutOfRangeException, InvalidCastException, InvalidOperationException
                >(() => throw new ArgumentNullException());
            Assert.False(actual);

            actual =
                ActionEx
                .SafeExecute
                <ArgumentNullException, ArgumentOutOfRangeException, InvalidCastException, InvalidOperationException
                >(() => throw new ArgumentOutOfRangeException());
            Assert.False(actual);

            actual =
                ActionEx
                .SafeExecute
                <ArgumentNullException, ArgumentOutOfRangeException, InvalidCastException, InvalidOperationException
                >(() => throw new InvalidCastException());
            Assert.False(actual);

            actual =
                ActionEx
                .SafeExecute
                <ArgumentNullException, ArgumentOutOfRangeException, InvalidCastException, InvalidOperationException
                >(() => throw new InvalidOperationException());
            Assert.False(actual);
        }