Example #1
0
        public void CreateGalleryItemCommentRequest_WithUrlNull_ThrowsArgumentNullException()
        {
            var requestBuilder = new CommentRequestBuilder();

            var exception = Record.Exception(() => CommentRequestBuilder.CreateGalleryItemCommentRequest(null, "Hello World!"));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "url");
        }
Example #2
0
        public void CreateGalleryItemCommentRequest_WithCommentNull_ThrowsArgumentNullException()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new CommentRequestBuilder();
            var mockUrl        = $"{client.EndpointUrl}comment";

            var exception = Record.Exception(() => CommentRequestBuilder.CreateGalleryItemCommentRequest(mockUrl, null));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);

            var argNullException = (ArgumentNullException)exception;

            Assert.Equal(argNullException.ParamName, "comment");
        }
Example #3
0
        public async Task CreateGalleryItemCommentRequest_Equal()
        {
            var client         = new ImgurClient("123", "1234");
            var requestBuilder = new CommentRequestBuilder();

            var mockUrl = $"{client.EndpointUrl}gallery/XysioD/comment";
            var request = CommentRequestBuilder.CreateGalleryItemCommentRequest(mockUrl, "Hello World!");

            Assert.NotNull(request);
            var expected = "comment=Hello+World%21";

            Assert.Equal(expected, await request.Content.ReadAsStringAsync().ConfigureAwait(false));
            Assert.Equal("https://api.imgur.com/3/gallery/XysioD/comment", request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Post, request.Method);
        }