Example #1
0
 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);
     }
 }
Example #2
0
 public void PutPost(PostContent p)
 {
     postRepo.UpdateEntity(p);
 }
Example #3
0
 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);
 }
Example #4
0
 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);
 }
Example #5
0
 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);
 }
Example #6
0
 public void TearDown()
 {
     post = null;
 }
Example #7
0
 public void SetUp()
 {
     post = new PostContent();
 }