public AsyncTryFrame( TryFrameType frameType, Func <object, Task <object> > action, AsyncCatchClause catchClause) : base(frameType, catchClause) { Action = action; }
public void CanCreate() { Func <Exception, Task <object> > handler = async exception => 9; var type = typeof(ArithmeticException); var x = new AsyncCatchClause(handler, type); Assert.AreSame(handler, x.Handler); Assert.AreEqual(type, x.ExceptionType); }
public void CanDetermineHandlerCompatibility() { Func <Exception, Task <object> > handler = async exception => 9; var type = typeof(OperationCanceledException); var x = new AsyncCatchClause(handler, type); Assert.IsTrue(x.CanHandle(new OperationCanceledException())); Assert.IsTrue(x.CanHandle(new TaskCanceledException())); Assert.IsFalse(x.CanHandle(new ArithmeticException())); Assert.IsFalse(x.CanHandle(new ArgumentNullException())); }
public void CanCreate() { var type = TryFrameType.CatchClause; Func <object, Task <object> > action = async o => o; var clause = new AsyncCatchClause(async exception => 9, typeof(ArithmeticException)); var x = new AsyncTryFrame(type, action, clause); Assert.AreEqual(type, x.FrameType); Assert.AreSame(action, x.Action); Assert.AreSame(clause, x.CatchClause); }