示例#1
0
            public void ThrowsTargetInvocationException()
            {
                MethodInfo             method        = typeof(TestMethodCommandClass).GetMethod("ThrowsTargetInvocationException");
                IMethodInfo            wrappedMethod = Reflector.Wrap(method);
                TestMethodCommandClass obj           = new TestMethodCommandClass();

                Exception ex = Record.Exception(() => wrappedMethod.Invoke(obj));

                Assert.IsType <TargetInvocationException>(ex);
            }
示例#2
0
            public void TurnsTargetParameterCountExceptionIntoParameterCountMismatchException()
            {
                MethodInfo             method        = typeof(TestMethodCommandClass).GetMethod("ThrowsException");
                IMethodInfo            wrappedMethod = Reflector.Wrap(method);
                TestMethodCommandClass obj           = new TestMethodCommandClass();

                Exception ex = Record.Exception(() => wrappedMethod.Invoke(obj, "Hello world"));

                Assert.IsType <ParameterCountMismatchException>(ex);
            }
示例#3
0
        public void ThrowsException()
        {
            MethodInfo method = typeof(TestMethodCommandClass).GetMethod("ThrowsException");
            IMethodInfo wrappedMethod = Reflector.Wrap(method);
            TestMethodCommandClass obj = new TestMethodCommandClass();

            Exception ex = Record.Exception(() => wrappedMethod.Invoke(obj));

            Assert.IsType<InvalidOperationException>(ex);
        }
示例#4
0
        public void TurnsTargetParameterCountExceptionIntoParameterCountMismatchException()
        {
            MethodInfo method = typeof(TestMethodCommandClass).GetMethod("ThrowsException");
            IMethodInfo wrappedMethod = Reflector.Wrap(method);
            TestMethodCommandClass obj = new TestMethodCommandClass();

            Exception ex = Record.Exception(() => wrappedMethod.Invoke(obj, "Hello world"));

            Assert.IsType<ParameterCountMismatchException>(ex);
        }