public void GetAllPostsSuccess() { List <Post> posts = PostDB.GetAllPosts(active); postId = posts[0].Id; Assert.AreEqual(4, posts.Count); }
public void GetOnePostSuccess() { Guid id = PostDB.GetAllPosts(active)[0].Id; Post post = PostDB.GetPost(id); Assert.IsNotNull(post); }
public void DeletePostFailed() { int numberOfOldPosts = PostDB.GetAllPosts(active).Count; PostDB.DeletePost(Guid.NewGuid()); Assert.AreEqual(numberOfOldPosts, PostDB.GetAllPosts(active).Count); }
public void DeletePostSuccess() { Guid id = PostDB.GetAllPosts(active)[0].Id; PostDB.DeletePost(id); Assert.AreEqual(PostDB.GetPost(id).Active, false); }
public void InsertPostFailed() { Post post = new Post { Text = "", Rating = 2.5m, Views = 10, Location = "Novi Sad", Active = true, UserId = postId = Guid.NewGuid() }; int oldNumberOfPosts = PostDB.GetAllPosts(active).Count; PostDB.InsertPost(post); Assert.AreEqual(oldNumberOfPosts, PostDB.GetAllPosts(active).Count); }
public void UpdatePostFailed() { Guid id = PostDB.GetAllPosts(active)[0].Id; Post post = new Post { Text = "", Rating = 3.5m, Views = 12, Attachment = null, Location = "Another update", Active = true, UserId = postId = Guid.NewGuid() }; Post updatedPost = PostDB.UpdatePost(post, id); Assert.IsNull(updatedPost); }
public void InsertPostSuccess() { List <Post> posts = PostDB.GetAllPosts(active); Post post = new Post { Text = "new post text", Rating = 2.5m, Views = 10, Attachment = "attt", Location = "Novi Sad", Active = true, UserId = postId = posts[0].UserId }; int oldNumberOfPosts = PostDB.GetAllPosts(active).Count; PostDB.InsertPost(post); Assert.AreEqual(oldNumberOfPosts + 1, PostDB.GetAllPosts(active).Count); }
public IHttpActionResult Get() { try { Post[] temp = PostDB.GetAllPosts().ToArray(); if (temp != null) { return(Ok(temp)); } else { return(Content(HttpStatusCode.NotFound, "Posts cannot be found!")); } } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, ex)); } }
public void UpdatePostSuccess() { Guid id = PostDB.GetAllPosts(active)[0].Id; Post post = new Post { Text = "UpdateText", Rating = 3.5m, Views = 12, Attachment = "sadasd", Location = "Update Location", Active = true }; Post updatedPost = PostDB.UpdatePost(post, id); Assert.AreEqual(updatedPost.Text, post.Text); Assert.AreEqual(updatedPost.Rating, post.Rating); Assert.AreEqual(updatedPost.Views, post.Views); Assert.AreEqual(updatedPost.Attachment, post.Attachment); Assert.AreEqual(updatedPost.Location, post.Location); Assert.AreEqual(updatedPost.Active, post.Active); }
public IEnumerable <Post> GetAllPosts([FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active) { return(PostDB.GetAllPosts(active)); }