Ejemplo n.º 1
0
        public void DeletePostFailed()
        {
            int numberOfOldPosts = PostDB.GetAllPosts(active).Count;

            PostDB.DeletePost(Guid.NewGuid());
            Assert.AreEqual(numberOfOldPosts, PostDB.GetAllPosts(active).Count);
        }
Ejemplo n.º 2
0
        public void GetOnePostFailed()
        {
            int  id   = 100;
            Post post = PostDB.GetPost(id);

            Assert.IsNull(post);
        }
Ejemplo n.º 3
0
        public void DeletePostSuccess()
        {
            Guid id = PostDB.GetAllPosts(active)[0].Id;

            PostDB.DeletePost(id);
            Assert.AreEqual(PostDB.GetPost(id).Active, false);
        }
Ejemplo n.º 4
0
        public void DeletePostFailed()
        {
            int numberOfOldPosts = PostDB.GetPosts(active).Count;

            PostDB.DeletePost(123);
            Assert.AreEqual(numberOfOldPosts, PostDB.GetPosts(active).Count);
        }
Ejemplo n.º 5
0
        public void GetAllPostsSuccess()
        {
            List <Post> posts = PostDB.GetAllPosts(active);

            postId = posts[0].Id;
            Assert.AreEqual(4, posts.Count);
        }
Ejemplo n.º 6
0
        public void GetOnePostSuccess()
        {
            Guid id   = PostDB.GetAllPosts(active)[0].Id;
            Post post = PostDB.GetPost(id);

            Assert.IsNotNull(post);
        }
Ejemplo n.º 7
0
        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!!!"));
            }
        }
Ejemplo n.º 8
0
 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));
     }
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 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));
     }
 }
Ejemplo n.º 15
0
        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));
            }
        }
Ejemplo n.º 16
0
        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));
            }
        }
Ejemplo n.º 17
0
        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));
            }
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
 public Post GetPost(int id)
 {
     return(PostDB.GetPost(id));
 }
Ejemplo n.º 21
0
        public void GetAllPostsSuccess()
        {
            List <Post> posts = PostDB.GetPosts(active);

            Assert.AreEqual(1, posts.Count);
        }
Ejemplo n.º 22
0
 public IEnumerable <Post> GetAllPosts([FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active)
 {
     return(PostDB.GetAllPosts(active));
 }
Ejemplo n.º 23
0
        public void GetOnePostFailed()
        {
            Post post = PostDB.GetPost(Guid.NewGuid());

            Assert.IsNull(post);
        }
Ejemplo n.º 24
0
 public Post GetPost(Guid id)
 {
     return(PostDB.GetPost(id));
 }
Ejemplo n.º 25
0
 public IEnumerable <Post> GetPostsByUserId(Guid id, [FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active)
 {
     return(PostDB.GetPostsByUserId(id, active));
 }
Ejemplo n.º 26
0
 public Post InsertPost(Post post)
 {
     return(PostDB.InsertPost(post));
 }
Ejemplo n.º 27
0
 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>();
 }
Ejemplo n.º 29
0
 public void DeletePost(Guid id)
 {
     PostDB.DeletePost(id);
 }
Ejemplo n.º 30
0
 public void DeletePost(int id)
 {
     PostDB.DeletePost(id);
 }