public void CatchWithTaskTest() { //arrange Exception realEception = null; IPandaTask nextTask = new PandaTask(); IPandaTask NextTaskCallback(Exception ex) { realEception = ex; return(nextTask); } Exception excpectException = new Exception(); _task.Reject(excpectException); //act IPandaTask rejectTask = _task.Catch(NextTaskCallback); var castedTask = rejectTask as ContinuationTaskFromPandaTask; var callback = RuntimeReflection.GetValue <Func <IPandaTask>, ContinuationTaskFromPandaTask>(@"_nextActionDelegate", castedTask); IPandaTask realTask = callback(); //assert Assert.NotNull(castedTask); Assert.True(castedTask.FromCatch); Assert.AreEqual(realTask, nextTask); Assert.AreEqual(excpectException, realEception); }
public void ThenWithTaskTest() { //arrange Func <IPandaTask> expectedCallback = () => null; //act IPandaTask newtask = _task.Then(expectedCallback); var castedTask = newtask as ContinuationTaskFromPandaTask; var realCallback = RuntimeReflection.GetValue <Func <IPandaTask>, ContinuationTaskFromPandaTask>(@"_nextActionDelegate", castedTask); //assert Assert.NotNull(castedTask); Assert.False(castedTask.FromCatch); Assert.AreEqual(expectedCallback, realCallback); }