コード例 #1
0
        async Task <IEnumerable <IImage> > AccessTheWebAsync()
        {
            var client   = new ImgurClient(token);
            var endpoint = new GalleryEndpoint(client);
            var images   = await endpoint.GetGalleryAlbumAsync(gallerylink);

            return(images.Images);
        }
コード例 #2
0
        public async Task TestGetGalleryAlbum()
        {
            var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();

            var galleryEndpoint = new GalleryEndpoint(imgurClient);
            var response        = await galleryEndpoint.GetGalleryAlbumAsync("1S2u5");

            // Assert the Reponse
            Assert.IsNotNull(response.Data);
            Assert.AreEqual(response.Success, true);
            Assert.AreEqual(response.Status, HttpStatusCode.OK);
        }
コード例 #3
0
        public async Task GetAlbumAsync_WithIdNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new GalleryEndpoint(client);

            var exception =
                await
                Record.ExceptionAsync(
                    async() => await endpoint.GetGalleryAlbumAsync(null).ConfigureAwait(false))
                .ConfigureAwait(false);

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
コード例 #4
0
        //public async Task<IImage> GetPopularImages()
        //{
        //    var client = new ImgurClient("59b901759d20a52");
        //    var endpoint = new GalleryEndpoint(client);
        //    var gallery = await endpoint.GetGalleryAsync();

        //    foreach (var item in gallery)
        //    {
        //        if (item.GetType() == typeof(Imgur.API.Models.Impl.GalleryImage))
        //        {
        //            var endp = new ImageEndpoint(client);
        //            var im = endp.GetImageAsync(item.GetType().GetProperty("Id").GetValue(item).ToString());
        //            return im.Result;
        //        }
        //    }
        //    return null;
        //}

        async void GetAlbums()
        {
            var client   = new ImgurClient(ClientID);
            var endpoint = new GalleryEndpoint(client);
            var gallery  = await endpoint.GetGalleryAsync();

            foreach (var item in gallery)
            {
                if (item.GetType() == typeof(Imgur.API.Models.Impl.GalleryAlbum))
                {
                    var endp         = new GalleryEndpoint(client);
                    var galleryAlbum = endp.GetGalleryAlbumAsync(item.GetType().GetProperty("Id").GetValue(item).ToString());
                    Albums.Add(galleryAlbum.Result);
                }
            }
        }
コード例 #5
0
        public async Task GetAlbumAsync_NotNull()
        {
            var mockUrl      = "https://api.imgur.com/3/gallery/album/dO484";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockGalleryEndpointResponses.GetGalleryAlbum)
            };

            var client   = new ImgurClient("123", "1234");
            var endpoint = new GalleryEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var album    = await endpoint.GetGalleryAlbumAsync("dO484").ConfigureAwait(false);

            Assert.NotNull(album);
            Assert.Equal("dO484", album.Id);
            Assert.Equal("25 Films on Netflix I'd like to recommend.", album.Title);
            Assert.Equal(null, album.Description);
            Assert.Equal(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(1451445880), album.DateTime);
            Assert.Equal("xUPbs5g", album.Cover);
            Assert.Equal(700, album.CoverWidth);
            Assert.Equal(394, album.CoverHeight);
            Assert.Equal("bellsofwar3", album.AccountUrl);
            Assert.Equal(28720941, album.AccountId);
            Assert.Equal(AlbumPrivacy.Public, album.Privacy);
            Assert.Equal(AlbumLayout.Blog, album.Layout);
            Assert.Equal(13972, album.Views);
            Assert.Equal("http://imgur.com/a/dO484", album.Link);
            Assert.Equal(2024, album.Ups);
            Assert.Equal(28, album.Downs);
            Assert.Equal(1996, album.Points);
            Assert.Equal(1994, album.Score);
            Assert.Equal(null, album.Vote);
            Assert.Equal(false, album.Favorite);
            Assert.Equal(false, album.Nsfw);
            Assert.Equal("", album.Section);
            Assert.Equal(79, album.CommentCount);
            Assert.Equal("The More You Know", album.Topic);
            Assert.Equal(11, album.TopicId);
            Assert.Equal(25, album.ImagesCount);
            Assert.Equal(25, album.Images.Count());
        }
コード例 #6
0
		public async Task TestGetGalleryAlbum()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var galleryEndpoint = new GalleryEndpoint(imgurClient);
			var response = await galleryEndpoint.GetGalleryAlbumAsync("1S2u5");

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