public void IsValidForRequestThrowsIfControllerContextIsNull()
        {
            // Arrange
            AjaxOnlyAttribute attr = new AjaxOnlyAttribute();

            // Act & assert
            Assert.ThrowsArgumentNull(
                delegate { attr.IsValidForRequest(null, null); }, "controllerContext");
        }
        public void IsValidForRequestThrowsIfControllerContextIsNull()
        {
            // Arrange
            AjaxOnlyAttribute attr = new AjaxOnlyAttribute();

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                attr.IsValidForRequest(null, null);
            }, "controllerContext");
        }
        public void IsValidForRequestReturnsTrueIfHeaderIsPresent()
        {
            // Arrange
            AjaxOnlyAttribute attr = new AjaxOnlyAttribute();
            ControllerContext controllerContext = GetControllerContext(containsHeader: true);

            // Act
            bool isValid = attr.IsValidForRequest(controllerContext, null);

            // Assert
            Assert.True(isValid);
        }
        public void IsValidForRequestReturnsFalseIfHeaderNotPresent()
        {
            // Arrange
            AjaxOnlyAttribute attr = new AjaxOnlyAttribute();
            ControllerContext controllerContext = GetControllerContext(containsHeader: false);

            // Act
            bool isValid = attr.IsValidForRequest(controllerContext, null);

            // Assert
            Assert.IsFalse(isValid, "If the header *specifically* is not present, the attribute must decline matching the request.");
        }