public async Task GetAccountGalleryFavoritesAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException
     ()
 {
     var client   = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetAccountGalleryFavoritesAsync();
 }
Exemple #2
0
        public async Task GetAccountGalleryFavoritesAsync_Any_IsTrue()
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey);
            var endpoint = new AccountEndpoint(client);

            var favourites = await endpoint.GetAccountGalleryFavoritesAsync("sarah");

            Assert.IsTrue(favourites.Any());
        }
Exemple #3
0
        public async Task GetAccountGalleryFavoritesAsync_Any()
        {
            var client   = new ImgurClient(ClientId, ClientSecret, OAuth2Token);
            var endpoint = new AccountEndpoint(client);

            var favourites = await endpoint.GetAccountGalleryFavoritesAsync();

            Assert.IsTrue(favourites.Any());
        }
Exemple #4
0
        public async Task WithUsernameNull_ThrowsArgumentNullException_GetAccountGalleryFavoritesAsync()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

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

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Exemple #5
0
        public bool LoadFavorite()
        {
            Favorite.Clear();
            switch (Managers.Instance.service)
            {
            case SERVICE.FLICKR:
                if (Managers.Instance.user.Connected)
                {
                    var favorite = Managers.Instance.flicker.flickr.FavoritesGetList(Managers.Instance.flicker.accessToken.UserId);
                    foreach (var it in favorite)
                    {
                        if (!IsFavorite(it.PhotoId) && !IsIndesirable(it.PhotoId))
                        {
                            Favorite.Add(it.PhotoId);
                        }
                    }
                    return(true);
                }
                break;

            case SERVICE.IMGUR:
                if (Managers.Instance.user.Connected)
                {
                    var endpoint = new AccountEndpoint(Managers.Instance.imgur.Imgur);
                    var result   = endpoint.GetAccountGalleryFavoritesAsync();
                    result.Wait();
                    var list = result.Result;

                    foreach (var it in list)
                    {
                        if (it.GetType() == typeof(GalleryImage))
                        {
                            var img = it as GalleryImage;
                            Favorite.Add(img.Id);
                        }
                        else if (it.GetType() == typeof(GalleryAlbum))
                        {
                            var album = it as GalleryAlbum;
                            foreach (var img in album.Images)
                            {
                                Favorite.Add(img.Id);
                            }
                        }
                    }
                    return(true);
                }
                break;
            }
            return(false);
        }
Exemple #6
0
        public async Task Any_GetAccountGalleryFavoritesAsync()
        {
            const string mockUrl      = "https://api.imgur.com/3/account/me/gallery_favorites/2/oldest";
            var          mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetAccountGalleryFavorites)
            };

            var client    = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint  = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var favorites =
                await
                endpoint.GetAccountGalleryFavoritesAsync(page : 2, sort : AccountGallerySortOrder.Oldest)
                .ConfigureAwait(false);

            Assert.True(favorites.Any());
        }
        public async Task GetAccountGalleryFavoritesAsync_Any()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetAccountGalleryFavoritesResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var favorites         = await endpoint.GetAccountGalleryFavoritesAsync(page : 2, sort : GallerySortOrder.Oldest);

            Assert.IsTrue(favorites.Any());
        }
Exemple #8
0
        private void SearchFavoris(object sender, RoutedEventArgs e)
        {
            SearchMode();

            if (Managers.Instance.user.Connected)
            {
                Managers.Instance.nav.Page = 1;
                Pannel.Children.Clear();

                switch (Managers.Instance.service)
                {
                case SERVICE.FLICKR:
                    Managers.Instance.cache.Favorite.Clear();
                    var favorite = Managers.Instance.flicker.flickr.FavoritesGetList(Managers.Instance.flicker.accessToken.UserId);
                    foreach (var it in favorite)
                    {
                        if (!Managers.Instance.cache.IsFavorite(it.PhotoId) && !Managers.Instance.cache.IsIndesirable(it.PhotoId))
                        {
                            Managers.Instance.cache.Favorite.Add(it.PhotoId);
                        }
                        if (!Managers.Instance.user.AllowIndesirable)
                        {
                            if (!Managers.Instance.cache.IsIndesirable(it.PhotoId))
                            {
                                LoadImage(it.PhotoId, it.Title, it.Description, it.SmallUrl, it.MediumUrl, it.LargeUrl);
                            }
                        }
                        else
                        {
                            LoadImage(it.PhotoId, it.Title, it.Description, it.SmallUrl, it.MediumUrl, it.LargeUrl);
                        }
                    }
                    break;

                case SERVICE.IMGUR:
                    var endpoint = new AccountEndpoint(Managers.Instance.imgur.Imgur);
                    var result   = endpoint.GetAccountGalleryFavoritesAsync();
                    result.Wait();
                    var list = result.Result;

                    foreach (var it in list)
                    {
                        if (it.GetType() == typeof(GalleryImage))
                        {
                            var img = it as GalleryImage;
                            if (!Managers.Instance.user.AllowIndesirable)
                            {
                                if (!Managers.Instance.cache.IsIndesirable(img.Id))
                                {
                                    LoadImage(img.Id, img.Title, img.Description, img.Link, img.Link, img.Link);
                                }
                            }
                            else
                            {
                                LoadImage(img.Id, img.Title, img.Description, img.Link, img.Link, img.Link);
                            }
                        }
                        else if (it.GetType() == typeof(GalleryAlbum))
                        {
                            var album = it as GalleryAlbum;
                            foreach (var img in album.Images)
                            {
                                if (!Managers.Instance.user.AllowIndesirable)
                                {
                                    if (!Managers.Instance.cache.IsIndesirable(img.Id))
                                    {
                                        LoadImage(img.Id, img.Title, img.Description, img.Link, img.Link, img.Link, album.Id);
                                    }
                                }
                                else
                                {
                                    LoadImage(img.Id, img.Title, img.Description, img.Link, img.Link, img.Link, album.Id);
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }