当前位置: 首页>>代码示例>>C#>>正文


C# Impl.ImgurClient类代码示例

本文整理汇总了C#中Imgur.API.Authentication.Impl.ImgurClient的典型用法代码示例。如果您正苦于以下问题:C# ImgurClient类的具体用法?C# ImgurClient怎么用?C# ImgurClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImgurClient类属于Imgur.API.Authentication.Impl命名空间,在下文中一共展示了ImgurClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadImageBinaryRequest_WithImageNull_ThrowsArgumentNullException

 public void UploadImageBinaryRequest_WithImageNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var requestBuilder = new ImageRequestBuilder();
     var url = $"{client.EndpointUrl}image";
     requestBuilder.UploadImageBinaryRequest(url, null);
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:ImageRequestBuilderTests.cs

示例2: DeleteAlbumAsync_WithUsernameNull_ThrowsArgumentNullException

 public async Task DeleteAlbumAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2TokenHandler = new FakeOAuth2TokenHandler();
     var client = new ImgurClient("123", "1234", fakeOAuth2TokenHandler.GetOAuth2TokenCodeResponse());
     var endpoint = new AccountEndpoint(client);
     await endpoint.DeleteAlbumAsync("yMgB7", null);
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:AccountEndpointTests.Albums.cs

示例3: UploadImageBinaryRequest_AreEqual

        public async Task UploadImageBinaryRequest_AreEqual()
        {
            var client = new ImgurClient("123", "1234");
            var requestBuilder = new ImageRequestBuilder();
            var url = $"{client.EndpointUrl}image";

            var image = File.ReadAllBytes("banana.gif");
            var request = requestBuilder.UploadImageBinaryRequest(url, image, "TheAlbum", "TheTitle",
                "TheDescription");

            Assert.IsNotNull(request);
            Assert.AreEqual("https://api.imgur.com/3/image", request.RequestUri.ToString());
            Assert.AreEqual(HttpMethod.Post, request.Method);

            var content = (MultipartFormDataContent) request.Content;
            var imageContent =
                (ByteArrayContent) content.FirstOrDefault(x => x.Headers.ContentDisposition.Name == "image");
            var album = (StringContent) content.FirstOrDefault(x => x.Headers.ContentDisposition.Name == "album");
            var type = (StringContent) content.FirstOrDefault(x => x.Headers.ContentDisposition.Name == "type");
            var title = (StringContent) content.FirstOrDefault(x => x.Headers.ContentDisposition.Name == "title");
            var description =
                (StringContent) content.FirstOrDefault(x => x.Headers.ContentDisposition.Name == "description");

            Assert.IsNotNull(imageContent);
            Assert.IsNotNull(type);
            Assert.IsNotNull(album);
            Assert.IsNotNull(title);
            Assert.IsNotNull(description);

            Assert.AreEqual(image.Length, imageContent.Headers.ContentLength);
            Assert.AreEqual("file", await type.ReadAsStringAsync());
            Assert.AreEqual("TheAlbum", await album.ReadAsStringAsync());
            Assert.AreEqual("TheTitle", await title.ReadAsStringAsync());
            Assert.AreEqual("TheDescription", await description.ReadAsStringAsync());
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:35,代码来源:ImageRequestBuilderTests.cs

示例4: CreateReplyRequest_WithCommentNull_ThrowsArgumentNullException

 public void CreateReplyRequest_WithCommentNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var requestBuilder = new CommentRequestBuilder();
     var url = $"{client.EndpointUrl}comment";
     requestBuilder.CreateReplyRequest(url, null, "xYxAbcD");
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:CommentRequestBuilderTests.cs

示例5: AddAlbumImagesRequest_WithIdsNull_ThrowsArgumentNullException

 public void AddAlbumImagesRequest_WithIdsNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var requestBuilder = new AlbumRequestBuilder();
     var url = $"{client.EndpointUrl}album/AbcdeF/add";
     requestBuilder.AddAlbumImagesRequest(url, null);
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:AlbumRequestBuilderTests.cs

示例6: SendVerificationEmailAsync_IsTrue

        public async Task SendVerificationEmailAsync_IsTrue()
        {
            var client = new ImgurClient(ClientId, ClientSecret, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            await endpoint.SendVerificationEmailAsync();
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:ImgurClientWithOAuth2Tests.cs

示例7: HttpClientBaseAddress_WithImgurClient_IsImgurUrl

        public void HttpClientBaseAddress_WithImgurClient_IsImgurUrl()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            Assert.Equal(new Uri("https://api.imgur.com/3/"), endpoint.HttpClient.BaseAddress);
        }
开发者ID:DamienDennehy,项目名称:Imgur.API,代码行数:7,代码来源:EndpointBaseTests.cs

示例8: CreateCommentRequest_WithImageIdNull_ThrowsArgumentNullException

 public void CreateCommentRequest_WithImageIdNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var requestBuilder = new CommentRequestBuilder();
     var url = $"{client.EndpointUrl}comment";
     requestBuilder.CreateCommentRequest(url, "Hello World", null, "ABCdef");
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:CommentRequestBuilderTests.cs

示例9: GetAuthorizationUrl_SetState_AreEqual

 public void GetAuthorizationUrl_SetState_AreEqual()
 {
     var client = new ImgurClient("abc", "ioa");
     var endpoint = new OAuth2Endpoint(client);
     var expected = "https://api.imgur.com/oauth2/authorize?client_id=abc&response_type=Code&state=test";
     Assert.AreEqual(expected, endpoint.GetAuthorizationUrl(OAuth2ResponseType.Code, "test"));
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:OAuth2EndpointTests.cs

示例10: GetAuthorizationUrl_SetStateNull_AreEqual

 public void GetAuthorizationUrl_SetStateNull_AreEqual()
 {
     var client = new ImgurClient("xyz", "deb");
     var endpoint = new OAuth2Endpoint(client);
     var expected = "https://api.imgur.com/oauth2/authorize?client_id=xyz&response_type=Code&state=";
     Assert.AreEqual(expected, endpoint.GetAuthorizationUrl(OAuth2ResponseType.Code, null));
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:OAuth2EndpointTests.cs

示例11: ImgurClient

 public async Task GetAccountGalleryFavoritesAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException
     ()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetAccountGalleryFavoritesAsync();
 }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:7,代码来源:AccountEndpointTests.Gallery.cs

示例12: UpdateImageAsync_WithImage_AreEqual

        public async Task UpdateImageAsync_WithImage_AreEqual(IImage actualImage)
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new ImageEndpoint(client);

            var expected = await endpoint.UpdateImageAsync(actualImage.DeleteHash, "Ti", "De");

            Assert.IsTrue(expected);
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:9,代码来源:ImgurClientTests.cs

示例13: DeleteImageAsync_WithImage_IsTrue

        public async Task DeleteImageAsync_WithImage_IsTrue(IImage actualImage)
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new ImageEndpoint(client);

            var expected = await endpoint.DeleteImageAsync(actualImage.DeleteHash);

            Assert.IsTrue(expected);
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:9,代码来源:ImgurClientTests.cs

示例14: GetCommentsAsync_AreEqual

        public async Task GetCommentsAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var comments = await endpoint.GetCommentsAsync("sarah", CommentSortOrder.Best);

            Assert.AreEqual(50, comments.Count());
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:9,代码来源:ImgurClientTests.cs

示例15: GetCommentCountAsync_AreEqual

        public async Task GetCommentCountAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var commentCount = await endpoint.GetCommentCountAsync("sarah");

            Assert.IsTrue(commentCount > 100);
        }
开发者ID:Ranlaorn,项目名称:Imgur.API,代码行数:9,代码来源:ImgurClientTests.cs


注:本文中的Imgur.API.Authentication.Impl.ImgurClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。