Exemplo n.º 1
0
        public void GistCommentsTest()
        {
            var gistApi     = GetAuthenticatedGistApi();
            var createdGist = CreateGist(gistApi);

            var gistComments = gistApi.ListComments(createdGist.id);

            Assert.IsTrue(gistComments == null || new List <Core.Models.Comment>(gistComments).Count == 0);

            var gistComment = new Core.Models.CommentForCreationOrEdit {
                body = System.Guid.NewGuid().ToString()
            };

            var createdGistComment = gistApi.CreateComment(createdGist.id, gistComment);

            Assert.AreEqual(createdGistComment.body, gistComment.body);

            Assert.IsTrue(new List <Core.Models.Comment>(gistApi.ListComments(createdGist.id)).Count == 1);

            var editedGistCommentToSend = new Core.Models.CommentForCreationOrEdit {
                body = createdGistComment.body + " aha!"
            };

            var editedGistComment = gistApi.EditComment(createdGistComment.id,
                                                        editedGistCommentToSend);

            Assert.AreNotEqual(editedGistComment.body, createdGistComment.body);

            //To fast?
            //Assert.AreNotEqual(editedGistComment.created_at, createdGistComment.created_at);
            //Assert.IsTrue(editedGistComment.created_at >  createdGistComment.created_at);
            Assert.AreEqual(editedGistComment.body, editedGistCommentToSend.body);
            Assert.AreEqual(createdGistComment.id, editedGistComment.id);

            var retrievedComment = gistApi.GetComment(createdGistComment.id);

            Assert.AreEqual(editedGistComment.body, retrievedComment.body);
            Assert.AreEqual(createdGistComment.id, retrievedComment.id);
            Assert.AreEqual(editedGistComment.created_at, retrievedComment.created_at);

            gistApi.DeleteComment(retrievedComment.id);

            Assert.IsTrue(new List <Core.Models.Comment>(gistApi.ListComments(createdGist.id)).Count == 0);
        }
        public void GistCommentsTest()
        {
            var gistApi = GetAuthenticatedGistApi();
            var createdGist = CreateGist(gistApi);

            var gistComments = gistApi.ListComments(createdGist.id);

            Assert.IsTrue(gistComments == null || new List<Core.Models.Comment>(gistComments).Count == 0);

            var gistComment = new Core.Models.CommentForCreationOrEdit { body = System.Guid.NewGuid().ToString() };

            var createdGistComment = gistApi.CreateComment(createdGist.id, gistComment);

            Assert.AreEqual(createdGistComment.body, gistComment.body);

            Assert.IsTrue(new List<Core.Models.Comment>(gistApi.ListComments(createdGist.id)).Count == 1);

            var editedGistCommentToSend = new Core.Models.CommentForCreationOrEdit { body = createdGistComment.body + " aha!" };

            var editedGistComment = gistApi.EditComment(createdGistComment.id,
                editedGistCommentToSend);

            Assert.AreNotEqual(editedGistComment.body, createdGistComment.body);

            //To fast?
            //Assert.AreNotEqual(editedGistComment.created_at, createdGistComment.created_at);
            //Assert.IsTrue(editedGistComment.created_at >  createdGistComment.created_at);
            Assert.AreEqual(editedGistComment.body, editedGistCommentToSend.body);
            Assert.AreEqual(createdGistComment.id, editedGistComment.id);

            var retrievedComment = gistApi.GetComment(createdGistComment.id);

            Assert.AreEqual(editedGistComment.body, retrievedComment.body);
            Assert.AreEqual(createdGistComment.id, retrievedComment.id);
            Assert.AreEqual(editedGistComment.created_at, retrievedComment.created_at);

            gistApi.DeleteComment(retrievedComment.id);

            Assert.IsTrue(new List<Core.Models.Comment>(gistApi.ListComments(createdGist.id)).Count == 0);
        }