Ejemplo n.º 1
0
 public async Task DeleteCommentAsync_WithIdNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
     var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
     var endpoint          = new CommentEndpoint(client);
     await endpoint.DeleteCommentAsync(null);
 }
Ejemplo n.º 2
0
        public async Task DeleteCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new CommentEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.DeleteCommentAsync(678867866).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Ejemplo n.º 3
0
        public async Task DeleteCommentAsync_True()
        {
            var mockUrl      = "https://api.imgur.com/3/comment/6767676";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCommentEndpointResponses.DeleteComment)
            };

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var deleted  = await endpoint.DeleteCommentAsync(6767676).ConfigureAwait(false);

            Assert.True(deleted);
        }
Ejemplo n.º 4
0
        public async Task TestDeleteComment()
        {
            var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();

            var commentEndpoint = new CommentEndpoint(imgurClient);
            var comment         = await commentEndpoint.CreateCommentAsync("test reply", "161n8BB", 193421419);

            var deleteComment = await commentEndpoint.DeleteCommentAsync(comment.Data.Id);

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

            // Assert the Data
            Assert.AreEqual(deleteComment.Data, true);
        }
Ejemplo n.º 5
0
        public async Task DeleteCommentAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(CommentEndpointResponses.DeleteCommentResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/comment/12x5454"), fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var deleted           = await endpoint.DeleteCommentAsync("12x5454");

            Assert.IsTrue(deleted);
        }
Ejemplo n.º 6
0
 public async Task DeleteCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new CommentEndpoint(client);
     await endpoint.DeleteCommentAsync("12x5454");
 }