public async Task FavoriteAlbumAsync_WithIdNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
     var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
     var endpoint          = new AlbumEndpoint(client);
     await endpoint.FavoriteAlbumAsync(null);
 }
Пример #2
0
        public bool SetFavoriteAlbum(string id)
        {
            var endpoint_ = new AlbumEndpoint(Imgur);

            endpoint_.FavoriteAlbumAsync(id);
            return(true);
        }
        public async Task FavoriteAlbumAsync_WithImage_IsTrue(IAlbum actualAlbum)
        {
            var client   = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token);
            var endpoint = new AlbumEndpoint(client);

            var favorited = await endpoint.FavoriteAlbumAsync(actualAlbum.Id);

            Assert.IsTrue(favorited);
        }
Пример #4
0
        public async Task FavoriteAlbumAsync_WithMashapeClient_True()
        {
            var mockUrl      = "https://imgur-apiv3.p.mashape.com/3/album/zVpyzhW/favorite";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAlbumEndpointResponses.Imgur.FavoriteAlbumTrue)
            };

            var client    = new MashapeClient("123", "1234", "xyz", MockOAuth2Token);
            var endpoint  = new AlbumEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var favorited = await endpoint.FavoriteAlbumAsync("zVpyzhW").ConfigureAwait(false);

            Assert.True(favorited);
        }
Пример #5
0
        public async Task FavoriteAlbumAsync_WithIdNull_ThrowsArgumentNullException()
        {
            var client   = new ImgurClient("123", "1234", MockOAuth2Token);
            var endpoint = new AlbumEndpoint(client);

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

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Пример #6
0
        void likeAlbum(int position, LvHolder holder)
        {
            var endpoint = new AlbumEndpoint(client);

            ThreadPool.QueueUserWorkItem(o => endpoint.FavoriteAlbumAsync(images[position].Id));
            images[position].Favorite = !images[position].Favorite;
            if (images[position].Favorite)
            {
                holder.button.SetImageResource(Resource.Drawable.like);
            }
            else
            {
                holder.button.SetImageResource(Resource.Drawable.dislike);
            }
        }
        public async Task FavoriteAlbumAsync_WithMashapeClient_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AlbumEndpointResponses.Mashape.FavoriteAlbumResponseTrue)
            };

            fakeHttpMessageHandler.AddFakeResponse(
                new Uri("https://imgur-apiv3.p.mashape.com/3/album/zVpyzhW/favorite"), fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new MashapeClient("123", "1234", "xyz", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AlbumEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var favorited         = await endpoint.FavoriteAlbumAsync("zVpyzhW");

            Assert.IsTrue(favorited);
        }