Ejemplo n.º 1
0
        public void GetAllPostsSuccess()
        {
            List <Post> posts = PostDB.GetAllPosts(active);

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

            Assert.IsNotNull(post);
        }
Ejemplo n.º 3
0
        public void DeletePostFailed()
        {
            int numberOfOldPosts = PostDB.GetAllPosts(active).Count;

            PostDB.DeletePost(Guid.NewGuid());
            Assert.AreEqual(numberOfOldPosts, PostDB.GetAllPosts(active).Count);
        }
Ejemplo n.º 4
0
        public void DeletePostSuccess()
        {
            Guid id = PostDB.GetAllPosts(active)[0].Id;

            PostDB.DeletePost(id);
            Assert.AreEqual(PostDB.GetPost(id).Active, false);
        }
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
0
 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));
     }
 }
Ejemplo n.º 9
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.º 10
0
 public IEnumerable <Post> GetAllPosts([FromUri] ActiveStatusEnum active = ActiveStatusEnum.Active)
 {
     return(PostDB.GetAllPosts(active));
 }