Пример #1
0
 public async Task ReportCommentAsync_WithIdNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
     var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
     var endpoint          = new CommentEndpoint(client);
     await endpoint.ReportCommentAsync(null, ReportReason.Spam);
 }
Пример #2
0
        public async Task TestReportComment()
        {
            var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();

            var commentEndpoint = new CommentEndpoint(imgurClient);
            var comment         = await commentEndpoint.ReportCommentAsync(193420645);

            // Assert the Reponse
            Assert.AreEqual(comment.Success, true);
            Assert.AreEqual(comment.Status, HttpStatusCode.OK);
        }
Пример #3
0
        public async Task ReportCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new CommentEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() =>
                    await endpoint.ReportCommentAsync(539556821, ReportReason.Spam).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Пример #4
0
        public async Task ReportCommentAsync_True()
        {
            var mockUrl      = "https://api.imgur.com/3/comment/539556821/report";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCommentEndpointResponses.ReportComment)
            };

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var reported =
                await
                endpoint.ReportCommentAsync(539556821, ReportReason.MatureContentNotMarked).ConfigureAwait(false);

            Assert.True(reported);
        }
Пример #5
0
        public async Task ReportCommentAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(CommentEndpointResponses.ReportCommentResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var reported          = await endpoint.ReportCommentAsync("539556821", ReportReason.MatureContentNotMarked);

            Assert.IsTrue(reported);
        }
Пример #6
0
 public async Task ReportCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new CommentEndpoint(client);
     await endpoint.ReportCommentAsync("539556821", ReportReason.Spam);
 }