示例#1
0
        public void EndActionThrowsException()
        {
            IAsyncController controller = new ControllerWithAsyncActionThrowOnEnd();

            var context = services.ControllerContextFactory.
                          Create("", "ControllerWithAsyncAction", "index", services.ControllerDescriptorProvider.BuildDescriptor(controller));
            var exceptionCaught = false;

            services.ExtensionManager.ActionException += delegate { exceptionCaught = true; };

            try
            {
                var ar = controller.BeginProcess(engineContext, context);
                context.Async.Result = ar;
                ar.AsyncWaitHandle.WaitOne();
                controller.EndProcess();
                Assert.Fail("Expected exception");
            }
            catch (Exception)
            {
            }

            Assert.IsTrue(exceptionCaught);
        }
		public void EndActionThrowsException()
		{
			IAsyncController controller = new ControllerWithAsyncActionThrowOnEnd();

			var context = services.ControllerContextFactory.
				Create("", "ControllerWithAsyncAction", "index", services.ControllerDescriptorProvider.BuildDescriptor(controller));
			var exceptionCaught = false;
			services.ExtensionManager.ActionException += delegate { exceptionCaught = true; };

			try
			{
				var ar = controller.BeginProcess(engineContext, context);
				context.Async.Result = ar;
				ar.AsyncWaitHandle.WaitOne();
				controller.EndProcess();
				Assert.Fail("Expected exception");
			}
			catch(Exception)
			{
			}

			Assert.IsTrue(exceptionCaught);
		}