Exemplo n.º 1
0
 public async Task DeleteCommentAsync_WithDefaultUsernameAndOAuth2Null_ThrowsArgumentNullException()
 {
     var fakeOAuth2TokenHandler = new FakeOAuth2TokenHandler();
     var client   = new ImgurClient("123", "1234", fakeOAuth2TokenHandler.GetOAuth2TokenCodeResponse());
     var endpoint = new AccountEndpoint(client);
     await endpoint.DeleteCommentAsync("yMgB7", null);
 }
 public async Task DeleteImageAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2TokenHandler = new FakeOAuth2TokenHandler();
     var client   = new ImgurClient("123", "1234", fakeOAuth2TokenHandler.GetOAuth2TokenCodeResponse());
     var endpoint = new AccountEndpoint(client);
     await endpoint.DeleteImageAsync("hbzm7Ge", null);
 }
Exemplo n.º 3
0
 public async Task CreateReplyAsync_WithCommentNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
     var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
     var endpoint          = new CommentEndpoint(client);
     await endpoint.CreateReplyAsync(null, "xyz", "Abc");
 }
 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);
 }
Exemplo n.º 5
0
 public async Task VoteCommentAsync_WithIdNull_ThrowsArgumentNullException()
 {
     var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
     var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
     var endpoint          = new CommentEndpoint(client);
     await endpoint.VoteCommentAsync(null, Vote.Down);
 }
Exemplo n.º 6
0
        public async Task GetAccountSettingsAsync_AreEqual()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetAccountSettingsResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var accountSettings   = await endpoint.GetAccountSettingsAsync();

            Assert.AreEqual(true, accountSettings.AcceptedGalleryTerms);
            Assert.AreEqual("*****@*****.**", accountSettings.ActiveEmails.First());
            Assert.AreEqual(AlbumPrivacy.Secret, accountSettings.AlbumPrivacy);
            Assert.AreEqual(45454554, accountSettings.BlockedUsers.First().BlockedId);
            Assert.AreEqual("Bob", accountSettings.BlockedUsers.First().BlockedUrl);
            Assert.AreEqual("*****@*****.**", accountSettings.Email);
            Assert.AreEqual(false, accountSettings.HighQuality);
            Assert.AreEqual(true, accountSettings.MessagingEnabled);
            Assert.AreEqual(false, accountSettings.PublicImages);
            Assert.AreEqual(true, accountSettings.ShowMature);
        }
Exemplo n.º 7
0
        public async Task UpdateAccountSettingsAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.UpdateAccountSettingsResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var updated           = await endpoint.UpdateAccountSettingsAsync();

            Assert.IsTrue(updated);
        }
Exemplo n.º 8
0
        public async Task DeleteCommentAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(CommentEndpointResponses.DeleteCommentResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var deleted           = await endpoint.DeleteCommentAsync("12x5454");

            Assert.IsTrue(deleted);
        }
Exemplo n.º 9
0
        public async Task VerifyEmailAsync_ThrowsImgurException()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(AccountEndpointResponses.VerifyEmailErrorResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var updated           = await endpoint.VerifyEmailAsync();

            Assert.IsTrue(updated);
        }
        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());
        }
Exemplo n.º 11
0
        public async Task CreateReplyAsync_AreEqual()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(CommentEndpointResponses.CreateReplyResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/comment/BNMxDs"), fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var comment           = await endpoint.CreateReplyAsync("Hello World!", "xyz", "BNMxDs");

            Assert.IsNotNull(comment);
            Assert.AreEqual(539717441, comment.Id);
        }
Exemplo n.º 12
0
        public async Task VoteCommentAsync_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(CommentEndpointResponses.VoteCommentResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/comment/539556821/vote/down"),
                                                   fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var reported          = await endpoint.VoteCommentAsync("539556821", Vote.Down);

            Assert.IsTrue(reported);
        }
        public async Task GetGalleryProfileAsync_IsNotNull()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetGalleryProfileResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var profile           = await endpoint.GetGalleryProfileAsync();

            Assert.IsNotNull(profile);
        }
        public async Task GetAccountSubmissionsAsync_Any()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetAccountSubmissionsResponse)
            };

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

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var submissions       = await endpoint.GetAccountSubmissionsAsync(page : 2);

            Assert.IsTrue(submissions.Any());
        }
        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());
        }
        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);
        }
        public async Task DeleteImageAsync_IsNotNull()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.DeleteImageResponse)
            };

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

            var fakeOAuth2TokenHandler = new FakeOAuth2TokenHandler();
            var client   = new ImgurClient("123", "1234", fakeOAuth2TokenHandler.GetOAuth2TokenCodeResponse());
            var endpoint = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var deleted  = await endpoint.DeleteImageAsync("hbzm7Ge", "sarah");

            Assert.IsTrue(deleted);
        }
Exemplo n.º 18
0
        public async Task FavoriteImageAsync_WithImgurClient_IsTrue()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(ImageEndpointResponses.Imgur.FavoriteImageResponseTrue)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/image/zVpyzhW/favorite"),
                                                   fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();

            var client    = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint  = new ImageEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var favorited = await endpoint.FavoriteImageAsync("zVpyzhW");

            Assert.IsTrue(favorited);
        }
Exemplo n.º 19
0
        public async Task GetNotificationsAsync_IsNotNull()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse           = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetNotifications)
            };

            fakeHttpMessageHandler.AddFakeResponse(
                new Uri("https://api.imgur.com/3/account/me/notifications?new=false"), fakeResponse);

            var fakeOAuth2Handler = new FakeOAuth2TokenHandler();
            var client            = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse());
            var endpoint          = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var notifications     = await endpoint.GetNotificationsAsync(false);

            Assert.IsNotNull(notifications);
            Assert.IsNotNull(notifications.Messages);
            Assert.IsNotNull(notifications.Replies);
        }