public void OnAuthorizationThrowsIfFilterContextIsNull()
        {
            // Arrange
            ValidateInputAttribute attr = new ValidateInputAttribute(true);

            // Act & assert
            Assert.ThrowsArgumentNull(
                delegate { attr.OnAuthorization(null); }, "filterContext");
        }
Exemple #2
0
        public void OnAuthorizationThrowsIfFilterContextIsNull()
        {
            // Arrange
            ValidateInputAttribute attr = new ValidateInputAttribute(true);

            // Act & assert
            Assert.ThrowsArgumentNull(
                delegate { attr.OnAuthorization(null); }, "filterContext");
        }
        public void OnAuthorizationSetsControllerValidateRequestToTrue()
        {
            // Arrange
            Controller controller = new EmptyController() { ValidateRequest = false };
            ValidateInputAttribute attr = new ValidateInputAttribute(enableValidation: true);
            AuthorizationContext authContext = GetAuthorizationContext(controller);

            // Act
            attr.OnAuthorization(authContext);

            // Assert
            Assert.True(controller.ValidateRequest);
        }
Exemple #4
0
        public void OnAuthorizationSetsControllerValidateRequestToTrue()
        {
            // Arrange
            Controller controller = new EmptyController()
            {
                ValidateRequest = false
            };
            ValidateInputAttribute attr        = new ValidateInputAttribute(enableValidation: true);
            AuthorizationContext   authContext = GetAuthorizationContext(controller);

            // Act
            attr.OnAuthorization(authContext);

            // Assert
            Assert.True(controller.ValidateRequest);
        }