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