public static void RecordExceptionReturnsExceptionFromAwaitableObjectResult() { var exceptionToThrow = new Exception(); Assert.That( ExceptionHelper.RecordException(new Func <Task>(() => TaskFromException(exceptionToThrow)), "someParamName"), Is.SameAs(exceptionToThrow)); }
public static void RecordExceptionThrowsProperExceptionForDelegatesThatHaveOneMoreParameterThanTheBoundMethod() { var methodInfo = typeof(Foo).GetMethod(nameof(Foo.DummyInstanceMethod)); var delegateThatParameterizesTheInstance = (Action <Foo>)methodInfo.CreateDelegate(typeof(Action <Foo>)); Assert.That( () => ExceptionHelper.RecordException(delegateThatParameterizesTheInstance, "someParamName"), Throws.ArgumentException); }
public static void RecordExceptionHandlesDelegatesThatHaveOneFewerParameterThanTheBoundMethod() { Assert.That( ExceptionHelper.RecordException(new TestDelegate(new Foo(null).ThrowingExtensionMethod), "someParamName"), Is.Null); var exceptionToThrow = new Exception(); Assert.That( ExceptionHelper.RecordException(new TestDelegate(new Foo(exceptionToThrow).ThrowingExtensionMethod), "someParamName"), Is.SameAs(exceptionToThrow)); }
public static void RecordExceptionThrowsForDelegateThatRequiresParameters() { Assert.That( () => ExceptionHelper.RecordException(new Action <object>(_ => { }), "someParamName"), Throws.ArgumentException.With.Property("ParamName").EqualTo("someParamName")); }
public static void RecordExceptionThrowsForNullDelegate() { Assert.That( () => ExceptionHelper.RecordException(null, "someParamName"), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("someParamName")); }