public void Id_Invalid_string_Should_Return_BadRequest()
        {
            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/post");
            request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var httpControllerContext = new HttpControllerContext {
                 Request = request
            };

            var httpActionContext = new HttpActionContext {
                ControllerContext = httpControllerContext
            };

            httpActionContext.ModelState.AddModelError("id", "string is not a int");

            // Testing filter
            var filter = new ModelValidationFilterBase();
            filter.OnActionExecuting(httpActionContext);

            filter = new IdValidationFilterAttribute();
            filter.OnActionExecuting(httpActionContext);

            Assert.IsFalse(httpActionContext.ModelState.IsValid);
            Assert.IsTrue(httpActionContext.Response.StatusCode == HttpStatusCode.BadRequest);
            Assert.IsTrue(((Dictionary<string, IEnumerable<string>>) ((ObjectContent) (httpActionContext.Response.Content)).Value)["id"].FirstOrDefault() == "string is not a int");
        }
        public void Id_Valid_Should_Return_Ok()
        {
            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/post");
            request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            var httpControllerContext = new HttpControllerContext {
                 Request = request
            };

            var httpActionContext = new HttpActionContext {
                ControllerContext = httpControllerContext
            };

            httpActionContext.ModelState.Add("id", new ModelState() { Value = new ValueProviderResult(25, "25", CultureInfo.CurrentCulture)});

            // Testing filter
            var filter = new ModelValidationFilterBase();
            filter.OnActionExecuting(httpActionContext);

            filter = new IdValidationFilterAttribute();
            filter.OnActionExecuting(httpActionContext);

            Assert.IsTrue(httpActionContext.ModelState.IsValid);
            Assert.IsNull(httpActionContext.Response);
        }