async Task <IEnumerable <MyImage> > IApi.GetAccountImages() { var imgIds = await accountEndpoint.GetImageIdsAsync(); ObservableCollection <MyImage> Images = new ObservableCollection <MyImage>(); foreach (var imgId in imgIds) { var img = new MyImage(); var image = await this.GetImageFromId(imgId); img.Source = image.Link; img.Id = imgId; if (image.Favorite == true) { img.Favorite = "\uEB52;"; } else { img.Favorite = "\uEB51;"; } Images.Add(img); } return(Images); }
public async Task GetImageIdsAsync_Any() { var client = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token); var endpoint = new AccountEndpoint(client); var images = await endpoint.GetImageIdsAsync(); Assert.IsTrue(images.Count() > 1); }
public async Task GetImageIdsAsync_WithValidReponse_AreEqual() { var client = new MashapeClient(ClientId, ClientSecret, MashapeKey, await GetOAuth2Token()); var endpoint = new AccountEndpoint(client); var images = await endpoint.GetImageIdsAsync(); Assert.IsTrue(images.Count() > 1); }
public async Task GetImageIdsAsync_WithUsernameNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); var exception = await Record.ExceptionAsync( async() => await endpoint.GetImageIdsAsync(null).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); }
public async Task GetImageIdsAsync_Equal() { var mockUrl = "https://api.imgur.com/3/account/sarah/images/ids/2"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockAccountEndpointResponses.GetImageIds) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var images = await endpoint.GetImageIdsAsync("sarah", 2).ConfigureAwait(false); Assert.Equal(2, images.Count()); }
public async Task GetImageIdsAsync_AreEqual() { var fakeHttpMessageHandler = new FakeHttpMessageHandler(); var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(AccountEndpointResponses.GetImageIdsResponse) }; fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/sarah/images/ids/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.GetImageIdsAsync("sarah", 2); Assert.AreEqual(2, images.Count()); }
public async Task GetImageIdsAsync_WithUsernameNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); await endpoint.GetImageIdsAsync(null); }