Inheritance: System.Web.Mvc.Async.AsyncActionDescriptor
        public void ShouldImplement_AsyncActionDescriptor()
        {
            var actionMethod = typeof(TaskController).GetMethod("MethodReturningTask");

            var subjectUnderTest = new ReflectedTaskPatternActionDescriptor(actionMethod, null);

            Assert.IsInstanceOf<AsyncActionDescriptor>(subjectUnderTest);
        }
        public void ShouldHandleTasksWithNoReturnValue()
        {
            var controllerContext = MockRepository.GenerateStub<ControllerContext>();
            controllerContext.Controller = new TaskController();

            var actionMethod = typeof(TaskController).GetMethod("MethodReturningTaskWithNoResult");

            var subjectUnderTest = new ReflectedTaskPatternActionDescriptor(actionMethod, null);

            AsyncCallback callback = ar => subjectUnderTest.EndExecute(ar);

            var task = Task<object>.Factory.FromAsync(
                subjectUnderTest.BeginExecute(controllerContext, null, callback, null),
                subjectUnderTest.EndExecute);

            Assert.IsNull(task.Result);
        }
        public void ShouldReturnTaskResultWhenExecutedAsynchronously()
        {
            var controllerContext = MockRepository.GenerateStub<ControllerContext>();
            controllerContext.Controller = new TaskController();

            var actionMethod = typeof(TaskController).GetMethod("MethodReturningTask");

            var subjectUnderTest = new ReflectedTaskPatternActionDescriptor(actionMethod, null);
            
            AsyncCallback callback = ar => subjectUnderTest.EndExecute(ar);

            var task = Task<object>.Factory.FromAsync(
                subjectUnderTest.BeginExecute(controllerContext, null, callback, null),
                subjectUnderTest.EndExecute);

            Assert.IsInstanceOf<ViewResult>(task.Result);
        }