public void DeletePostFailed() { int numberOfOldPosts = PostDB.GetAllPosts(active).Count; PostDB.DeletePost(Guid.NewGuid()); Assert.AreEqual(numberOfOldPosts, PostDB.GetAllPosts(active).Count); }
public void GetOnePostFailed() { int id = 100; Post post = PostDB.GetPost(id); Assert.IsNull(post); }
public void DeletePostSuccess() { Guid id = PostDB.GetAllPosts(active)[0].Id; PostDB.DeletePost(id); Assert.AreEqual(PostDB.GetPost(id).Active, false); }
public void DeletePostFailed() { int numberOfOldPosts = PostDB.GetPosts(active).Count; PostDB.DeletePost(123); Assert.AreEqual(numberOfOldPosts, PostDB.GetPosts(active).Count); }
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 IHttpActionResult Delete(int id) { int val = PostDB.DeletePost(id); if (val > 0) { return(Ok($"Post with id {id} Successfully deleted!")); } else { return(Content(HttpStatusCode.NotFound, $"Post with id {id} was not found to delete!!!")); } }
public IHttpActionResult Post([FromBody] Post post) { try { int newCode = PostDB.InsertNewPost(post); post.PostId = newCode; return(Created(new Uri(Request.RequestUri.AbsoluteUri + $"/GetPostById/{post.PostId}"), post)); } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, ex)); } }
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() { Post post = new Post { Created = new DateTime(2018, 3, 3, 5, 0, 0), Text = "Danas pravimo microservice", Attachment = Encoding.ASCII.GetBytes("slika"), Location = "Novi sad", Rating = 3.2m, Clicks = 7, Active = true, UserId = 1 }; int oldNumberOfPosts = PostDB.GetPosts(active).Count; PostDB.InsertPost(post); Assert.AreEqual(oldNumberOfPosts + 1, PostDB.GetPosts(active).Count); }
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 void UpdatePostFailed() { int id = 100; Post post = new Post { Created = new DateTime(2018, 3, 3, 5, 0, 0), Text = "Danas pravimo microservice_UPDATE", Attachment = Encoding.ASCII.GetBytes("slika"), Location = "Novi sad", Rating = 3.2m, Clicks = 7, Active = true, UserId = 1 }; Post updatedPost = PostDB.UpdatePost(post, id); Assert.IsNull(updatedPost); }
public IHttpActionResult GetAllPostOfPartners() { try { ExtendedPost[] temp = PostDB.AllPostOfPartners().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 IHttpActionResult Put([FromBody] Post post) { try { int val = PostDB.UpdatePost(post); if (val > 0) { return(Content(HttpStatusCode.OK, post)); } else { return(Content(HttpStatusCode.NotFound, $"{post.Description} with id {post.PostId} was not found to update!")); } } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, ex)); } }
public IHttpActionResult PostsOfPartnersByUserId(int id) { try { ExtendedPost[] p = PostDB.PostsOfPartnersByUserId(id).ToArray(); if (p != null) { return(Ok(p)); } else { return(Content(HttpStatusCode.NotFound, "Posts dont found!")); } } catch (Exception ex) { return(Content(HttpStatusCode.BadRequest, ex)); } }
public IHttpActionResult Get(int id) { try { Post p = PostDB.GetPostById(id); if (p != null) { return(Ok(p)); } else { return(Content(HttpStatusCode.NotFound, "Post dont 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 void UpdatePostSuccess() { int id = PostDB.GetPosts(active)[0].Id; Post post = new Post { Created = new DateTime(2018, 3, 3, 5, 0, 0), Text = "Danas pravimo microservice_UPDATE", Attachment = Encoding.ASCII.GetBytes("slika"), Location = "Novi sad", Rating = 3.2m, Clicks = 7, Active = true, UserId = 1 }; Post localPost = PostDB.GetPost(id); post.Created = localPost.Created; post.UserId = localPost.UserId; PostDB.UpdatePost(post, id); Post updatedPost = PostDB.GetPost(id); Assert.AreEqual(updatedPost.Text, post.Text); }
public Post GetPost(int id) { return(PostDB.GetPost(id)); }
public void GetAllPostsSuccess() { List <Post> posts = PostDB.GetPosts(active); Assert.AreEqual(1, posts.Count); }
public IEnumerable <Post> GetAllPosts([FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active) { return(PostDB.GetAllPosts(active)); }
public void GetOnePostFailed() { Post post = PostDB.GetPost(Guid.NewGuid()); Assert.IsNull(post); }
public Post GetPost(Guid id) { return(PostDB.GetPost(id)); }
public IEnumerable <Post> GetPostsByUserId(Guid id, [FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active) { return(PostDB.GetPostsByUserId(id, active)); }
public Post InsertPost(Post post) { return(PostDB.InsertPost(post)); }
public Post UpdatePost([FromBody] Post post, Guid id) { return(PostDB.UpdatePost(post, id)); }
public override void OnStartServer() { netMan = GameObject.Find("NetMan").GetComponent <NetworkManager>(); db = netMan.GetComponent <PostDB>(); }
public void DeletePost(Guid id) { PostDB.DeletePost(id); }
public void DeletePost(int id) { PostDB.DeletePost(id); }