Ejemplo n.º 1
0
 public AsyncTryFrame(
     TryFrameType frameType,
     Func <object, Task <object> > action,
     AsyncCatchClause catchClause)
     : base(frameType, catchClause)
 {
     Action = action;
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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()));
        }
Ejemplo n.º 4
0
        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);
        }