public HttpResponseMessage Post(PostContent post) { if (ModelState.IsValid) { PostContent p = postRepo.CreateEntity(post); return new HttpResponseMessage(HttpStatusCode.Created); } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
public void PutPost(PostContent p) { postRepo.UpdateEntity(p); }
public void Test_if_controlller_can_CREATE_a_post_when_modelstate_is_wrong() { //PostContent requires all attributes filled out due to data annotation //In this case post is missing the imageurl and it should return a badrequest PostContent post = new PostContent() { Title = "I'm a Post", Description = "This is me writing something to display" }; HttpResponseMessage output = controller.Post(post); Assert.AreEqual(HttpStatusCode.BadRequest, output.StatusCode); }
public void Test_if_controller_can_CREATE_a_post() { PostContent post = new PostContent() { Title = "I'm a Post", Description = "This is me writing something to display", ImageUrl = "Just another Image url" }; HttpResponseMessage output = controller.Post(post); Assert.AreEqual(HttpStatusCode.Created, output.StatusCode); }
public void Test_if_create_post_works() { PostContent p = new PostContent() { Description = "Hello World", ImageUrl = "imgurl", Title = "Im a Test post" }; PostContent createdPost = postRepo.CreateEntity(p); Assert.Greater(createdPost.Id, 0); }
public void TearDown() { post = null; }
public void SetUp() { post = new PostContent(); }