public async Task GetAccountSubmissionsAsync_Any() { var client = new ImgurClient(ClientId, ClientSecret, OAuth2Token); var endpoint = new AccountEndpoint(client); var submissions = await endpoint.GetAccountSubmissionsAsync(); Assert.IsTrue(submissions.Any()); }
public async Task GetAccountSubmissionsAsync_Any_IsTrue() { var client = new MashapeClient(ClientId, ClientSecret, MashapeKey); var endpoint = new AccountEndpoint(client); var submissions = await endpoint.GetAccountSubmissionsAsync("sarah"); Assert.IsTrue(submissions.Any()); }
public async Task Any_GetAccountSubmissionsAsync() { const string mockUrl = "https://api.imgur.com/3/account/me/submissions/2"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockAccountEndpointResponses.GetAccountSubmissions) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var submissions = await endpoint.GetAccountSubmissionsAsync(page : 2).ConfigureAwait(false); Assert.True(submissions.Any()); }
public async Task WithUsernameNull_ThrowsArgumentNullException_GetAccountSubmissionsAsync() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); var exception = await Record.ExceptionAsync( async() => await endpoint.GetAccountSubmissionsAsync(null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); }
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()); }
private void DisplayUploaded(object sender, RoutedEventArgs e) { SearchMode(); Pannel.Children.Clear(); if (Managers.Instance.user.Connected) { Managers.Instance.nav.Page = 1; Pannel.Children.Clear(); switch (Managers.Instance.service) { case SERVICE.FLICKR: var options = new PartialSearchOptions { Extras = PhotoSearchExtras.Description | PhotoSearchExtras.Usage, PerPage = Managers.Instance.nav.ImagePerPage, Page = Managers.Instance.nav.Page }; PhotoCollection photos = Managers.Instance.flicker.flickr.PhotosGetNotInSet(options); foreach (Photo photo in photos) { LoadImage(photo.PhotoId, photo.Title, photo.Description, photo.SmallUrl, photo.MediumUrl, photo.LargeUrl); } break; case SERVICE.IMGUR: var endpoint = new AccountEndpoint(Managers.Instance.imgur.Imgur); var result = endpoint.GetAccountSubmissionsAsync(); 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); } } else { LoadImage(img.Id, img.Title, img.Description, img.Link, img.Link, img.Link); } } } } break; } ScrollPannel.ScrollToTop(); } }
public async Task GetAccountSubmissionsAsync_WithUsernameNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); await endpoint.GetAccountSubmissionsAsync(null); }