コード例 #1
0
        public void DurationProperty() {
            // Act
            AsyncTimeoutAttribute attr = new AsyncTimeoutAttribute(45);

            // Assert
            Assert.AreEqual(45, attr.Duration);
        }
コード例 #2
0
        public void OnActionExecutingThrowsIfFilterContextIsNull() {
            // Arrange
            AsyncTimeoutAttribute attr = new AsyncTimeoutAttribute(45);

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    attr.OnActionExecuting(null);
                }, "filterContext");
        }
コード例 #3
0
        public void OnActionExecutingThrowsIfControllerIsNotAsyncManagerContainer() {
            // Arrange
            AsyncTimeoutAttribute attr = new AsyncTimeoutAttribute(45);

            ActionExecutingContext filterContext = new ActionExecutingContext() {
                Controller = new MyController()
            };

            // Act & assert
            ExceptionHelper.ExpectInvalidOperationException(
                delegate {
                    attr.OnActionExecuting(filterContext);
                },
                @"The controller of type 'System.Web.Mvc.Test.AsyncTimeoutAttributeTest+MyController' must subclass AsyncController or implement the IAsyncManagerContainer interface.");
        }
コード例 #4
0
        public void OnActionExecutingSetsTimeoutPropertyOnController() {
            // Arrange
            AsyncTimeoutAttribute attr = new AsyncTimeoutAttribute(45);

            MyAsyncController controller = new MyAsyncController();
            controller.AsyncManager.Timeout = 0;

            ActionExecutingContext filterContext = new ActionExecutingContext() {
                Controller = controller
            };

            // Act
            attr.OnActionExecuting(filterContext);

            // Assert
            Assert.AreEqual(45, controller.AsyncManager.Timeout);
        }