public async Task GetImagesAsync_WithValidReponse_AreEqual()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var images = await endpoint.GetImagesAsync();

            Assert.IsTrue(images.Count() >= 2);
        }
예제 #2
0
        public async Task GetImagesAsync_Any()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var images = await endpoint.GetImagesAsync();

            Assert.IsTrue(images.Any());
        }
예제 #3
0
        public static async Task <IEnumerable <IImage> > GetUpl(UserInfo user)
        {
            var client = new ImgurClient("3f8dfa6f3541120", "dcb972ae2f6952efb8e9a156fe0c65b8136b3010");

            client.SetOAuth2Token(user.tokenObject);
            var endpoint = new AccountEndpoint(client);
            var favs     = await endpoint.GetImagesAsync();

            return(favs);
        }
        //renvoie le nombre de post par l'utilisateur
        public async Task <int> GetPostCount()
        {
            int count      = 0;
            var client_fav = new ImgurClient(client_id, imgur_token);
            var endpoint   = new AccountEndpoint(client_fav);
            var favourites = await endpoint.GetImagesAsync();

            for (int i = 0; i < favourites.Count(); i++)
            {
                count++;
            }
            return(count);
        }
예제 #5
0
        public async Task GetImagesAsync_WithUsernameNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

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

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
예제 #6
0
        public async Task GetImagesAsync_Equal()
        {
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetImages)
            };

            var mockUrl = "https://api.imgur.com/3/account/sarah/images/2";

            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var images   = await endpoint.GetImagesAsync("sarah", 2).ConfigureAwait(false);

            Assert.Equal(2, images.Count());
        }
        //renvoie les images postées par l'utilisateur

        /**
         * Return pictures posted from the user
         */
        public async Task <ImageContainer> createImageContainerFromPosts()
        {
            ImageContainer imageContainer = new ImageContainer();
            var            client_fav     = new ImgurClient(client_id, imgur_token);
            var            endpoint       = new AccountEndpoint(client_fav);
            var            favourites     = await endpoint.GetImagesAsync();

            for (int i = 0; i < favourites.Count(); i++)
            {
                Imgur.API.Models.Impl.Image    galleryImage = (Imgur.API.Models.Impl.Image)(favourites.ElementAt(i));
                Windows.UI.Xaml.Controls.Image imgImgur     = new Windows.UI.Xaml.Controls.Image();
                imgImgur.Source = new BitmapImage(new Uri(galleryImage.Link, UriKind.Absolute));
                imgImgur.Name   = galleryImage.Id;
                imageContainer.AddImageSource(imgImgur);
            }
            return(imageContainer);
        }
        public async Task GetImagesAsync_AreEqual()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetImagesResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/sarah/images/2"),
                                                   fakeResponse);

            var tokenHandler = new FakeOAuth2TokenHandler();
            var client       = new ImgurClient("123", "1234", tokenHandler.GetOAuth2TokenCodeResponse());
            var endpoint     = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var images       = await endpoint.GetImagesAsync("sarah", 2);

            Assert.AreEqual(2, images.Count());
        }
예제 #9
0
        private async Task GetImagesAsync(int delay, string query)
        {
            await Task.Delay(delay);

            var endpoint = new AccountEndpoint(currentUser);
            IEnumerable <IImage> images = await endpoint.GetImagesAsync();

            if (this.images != null)
            {
                this.images.Clear();
            }
            this.images = FilterClass <IImage> .convertList(query, images.ToList());

            _adapter = new LvImgBinder(this, Resource.Layout.listview_model, this.images, currentUser);
            RunOnUiThread(() =>
            {
                _lv.Adapter    = _adapter;
                _lv.ItemClick += lv_ItemClick;
            });
        }
 public async Task GetImagesAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetImagesAsync(null);
 }