Beispiel #1
0
        public async Task Comments_Query()
        {
            var queryBuilder = new CommentsQueryBuilder()
            {
                Page    = 1,
                PerPage = 15,
                OrderBy = CommentsOrderBy.Id,
                Order   = Order.DESC,
            };
            var queryresult = await _clientAuth.Comments.Query(queryBuilder);

            Assert.AreEqual("?page=1&per_page=15&orderby=id", queryBuilder.BuildQueryURL());
            Assert.IsNotNull(queryresult);
            Assert.AreNotSame(queryresult.Count(), 0);
        }
Beispiel #2
0
        public async Task Comments_Query()
        {
            var client = await ClientHelper.GetAuthenticatedWordPressClient();

            var queryBuilder = new CommentsQueryBuilder()
            {
                Page    = 1,
                PerPage = 15,
                OrderBy = CommentsOrderBy.Id,
                Order   = Order.DESC,
            };
            var queryresult = await client.Comments.Query(queryBuilder);

            Assert.AreEqual(queryBuilder.BuildQueryURL(), "?page=1&per_page=15&orderby=id&order=desc");
            Assert.IsNotNull(queryresult);
            Assert.AreNotSame(queryresult.Count(), 0);
        }
Beispiel #3
0
        // TODO: Can't create pending comment from Admin Account
        //[TestMethod]
        public async Task Comments_Query_Pending()
        {
            // Create new pending comment
            var posts = await _clientAuth.Posts.GetAll();

            var postId = posts.First().Id;
            var me     = await _clientAuth.Users.GetCurrentUser();

            // Create random content to prevent duplicate commment errors
            var random  = new Random();
            var content = $"TestComment {random.Next(0, 10000)}";
            var comment = new Comment()
            {
                Content     = new Content(content),
                PostId      = postId,
                AuthorId    = me.Id,
                AuthorEmail = "*****@*****.**",
                AuthorName  = me.Name,
                Status      = CommentStatus.Pending
            };
            var resultComment = await _clientAuth.Comments.Create(comment);

            Assert.IsNotNull(resultComment);
            Assert.AreEqual(CommentStatus.Pending, resultComment.Status);

            // this test needs a pending comment added manually for now.
            var queryBuilder = new CommentsQueryBuilder()
            {
                Page     = 1,
                PerPage  = 15,
                OrderBy  = CommentsOrderBy.Id,
                Order    = Order.DESC,
                Statuses = new CommentStatus[] { CommentStatus.Pending }
            };
            var queryresult = await _clientAuth.Comments.Query(queryBuilder, true);

            var querystring = "?page=1&per_page=15&orderby=id&status=hold";

            Assert.AreEqual(querystring, queryBuilder.BuildQueryURL());
            Assert.IsNotNull(queryresult);
            Assert.AreNotEqual(queryresult.Count(), 0);

            // Delete Pending comment
            await _clientAuth.Comments.Delete(resultComment.Id);
        }
Beispiel #4
0
        public async Task Comments_Query_Pending()
        {
            // this test needs a pending comment added manually for now.
            var queryBuilder = new CommentsQueryBuilder()
            {
                Page     = 1,
                PerPage  = 15,
                OrderBy  = CommentsOrderBy.Id,
                Order    = Order.DESC,
                Statuses = new CommentStatus[] { CommentStatus.Pending }
            };
            var queryresult = await _clientAuth.Comments.Query(queryBuilder, true);

            var querystring = "?page=1&per_page=15&orderby=id&status=hold";

            Assert.AreEqual(querystring, queryBuilder.BuildQueryURL());
            Assert.IsNotNull(queryresult);
            Assert.AreNotEqual(queryresult.Count(), 0);
        }
Beispiel #5
0
 /// <summary>
 /// Create a parametrized query and get a result
 /// </summary>
 /// <param name="queryBuilder">Comments query builder with specific parameters</param>
 /// <param name="useAuth">Send request with authenication header</param>
 /// <returns>List of filtered comments</returns>
 public async Task <IEnumerable <Comment> > Query(CommentsQueryBuilder queryBuilder, bool useAuth = false)
 {
     return(await _httpHelper.GetRequest <IEnumerable <Comment> >($"{_defaultPath}{_methodPath}{queryBuilder.BuildQueryURL()}", false, useAuth).ConfigureAwait(false));
 }