Example #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);
            }
Example #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);
            }
Example #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);
        }
Example #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);
        }