public APIResult TestImgur()
        {
            var client = new ImgurClient("2f3ed3db83e866d", "62a894b5e1dd5ed77cc5b4f10eea25e3ebc3e816"
                                         , new OAuth2Token("654c446bd2f20543284db4a2d986ea234d81b98b"
                                                           , "e3100d2d2fc8b14e9131dc1aad5b9a24ca8ee22c"
                                                           , "bearer"
                                                           , "132433023"
                                                           , "frankimg"
                                                           , 315360000));
            var    endpoint      = new ImageEndpoint(client);
            var    endpointAlbum = new AlbumEndpoint(client);
            IImage image;
            bool   success = false;

            //取得圖片檔案FileStream
            using (var fs = new FileStream(@"D:\Documents\build_school\project\finalProject1\SurvivalGameVer2\SurvivalGame\Assets\images\Product1.png", FileMode.Open))
            {
                image   = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
                success = endpointAlbum.AddAlbumImagesAsync("ZeSZMYK", new List <string>()
                {
                    image.Id
                }).GetAwaiter().GetResult();
            }

            return(new APIResult()
            {
                IsSuccess = true,
                //顯示圖檔位置
                Data = $"Image uploaded.Image Url:  + {image.Link} ,ImgId:{image.Id} ,success: {success}"
            });
        }
        public async Task AddAlbumImagesAsync_WithAlbum_AreEqual(IAlbum actualAlbum)
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token);
            var endpoint = new AlbumEndpoint(client);

            var updated =
                await
                endpoint.AddAlbumImagesAsync(actualAlbum.Id,
                                             new List <string> {
                "uH3kfZP", "VzbrLbO", "OkFyVOe", "Y8BbQuU"
            });

            Assert.IsTrue(updated);
        }
Example #3
0
        public async Task AddAlbumImagesAsync_WithIdNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AlbumEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.AddAlbumImagesAsync("12x5454", null).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
        public async Task AddAlbumImagesAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AlbumEndpointResponses.Imgur.AddAlbumImagesResponse)
            };

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

            var client   = new ImgurClient("123", "1234");
            var endpoint = new AlbumEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var updated  = await endpoint.AddAlbumImagesAsync("12x5454", new List <string> {
                "AbcDef", "IrcDef"
            });

            Assert.IsTrue(updated);
        }
Example #5
0
        public async Task AddAlbumImagesAsync_True()
        {
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAlbumEndpointResponses.Imgur.AddAlbumImages)
            };

            var mockUrl  = "https://api.imgur.com/3/album/12x5454/add";
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AlbumEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));

            var updated =
                await
                endpoint.AddAlbumImagesAsync("12x5454", new List <string> {
                "AbcDef", "IrcDef"
            }).ConfigureAwait(false);

            Assert.True(updated);
        }
 public async Task AddAlbumImagesAsync_WithIdNulls_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AlbumEndpoint(client);
     await endpoint.AddAlbumImagesAsync("12x5454", null);
 }