Esempio n. 1
0
        public async Task GetCommentAsync_True()
        {
            var mockUrl      = "https://api.imgur.com/3/comment/539556821";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCommentEndpointResponses.GetComment)
            };

            var client   = new ImgurClient("123", "1234");
            var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var comment  = await endpoint.GetCommentAsync(539556821).ConfigureAwait(false);

            Assert.NotNull(comment);
            Assert.Equal(539556821, comment.Id);
            Assert.Equal("n6gcXdY", comment.ImageId);
            Assert.Equal("It's called smirking. Lots of people do it.", comment.CommentText);
            Assert.Equal("WomanWiththeTattooedHands", comment.Author);
            Assert.Equal(499505, comment.AuthorId);
            Assert.Equal(false, comment.OnAlbum);
            Assert.Equal(null, comment.AlbumCover);
            Assert.Equal(379, comment.Ups);
            Assert.Equal(16, comment.Downs);
            Assert.Equal(363, comment.Points);
            Assert.Equal(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(1450526522), comment.DateTime);
            Assert.Equal(0, comment.ParentId);
            Assert.Equal("iphone", comment.Platform);
            Assert.Equal(false, comment.Deleted);
            Assert.Equal(VoteOption.Veto, comment.Vote);
        }
Esempio n. 2
0
        public async Task TestVoteComment()
        {
            var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();

            var commentEndpoint = new CommentEndpoint(imgurClient);
            var comment         = await commentEndpoint.GetCommentAsync(193421419);

            var votedComment = await commentEndpoint.VoteCommentAsync(comment.Data.Id, VoteDirection.Up);

            // Assert the Reponse
            Assert.IsNotNull(votedComment.Data);
            Assert.AreEqual(votedComment.Success, true);
            Assert.AreEqual(votedComment.Status, HttpStatusCode.OK);
        }
Esempio n. 3
0
        public async Task TestGetComment()
        {
            var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();

            var commentEndpoint = new CommentEndpoint(imgurClient);
            var comment         = await commentEndpoint.GetCommentAsync(192351802);

            // Assert the Reponse
            Assert.IsNotNull(comment.Data);
            Assert.AreEqual(comment.Success, true);
            Assert.AreEqual(comment.Status, HttpStatusCode.OK);

            // Assert the Data
            Assert.AreEqual(comment.Data.OnAlbum, false);
            Assert.AreEqual(comment.Data.AlbumCover, null);
            Assert.AreEqual(comment.Data.Author, "imgurnet");
        }
Esempio n. 4
0
        public async Task GetCommentAsync_False()
        {
            var mockUrl      = "https://api.imgur.com/3/comment/539556821";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCommentEndpointResponses.GetCommentNotExists)
            };

            var client   = new ImgurClient("123", "1234");
            var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.GetCommentAsync(539556821).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ImgurException>(exception);
        }
Esempio n. 5
0
 public async Task GetCommentAsync_WithIdNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new CommentEndpoint(client);
     await endpoint.GetCommentAsync(null);
 }