public async Task UpdateAccountSettingsAsync_IsTrue() { var client = new MashapeClient(ClientId, ClientSecret, MashapeKey, OAuth2Token); var endpoint = new AccountEndpoint(client); var updated = await endpoint.UpdateAccountSettingsAsync("ImgurClient_" + DateTimeOffset.UtcNow, false, albumPrivacy : AlbumPrivacy.Hidden); Assert.IsTrue(updated); }
public async Task UpdateAccountSettingsAsync_True() { var mockUrl = "https://api.imgur.com/3/account/me/settings"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockAccountEndpointResponses.UpdateAccountSettings) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var updated = await endpoint.UpdateAccountSettingsAsync().ConfigureAwait(false); Assert.True(updated); }
public async Task UpdateAccountSettingsAsync_OAuth2Null_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); var exception = await Record.ExceptionAsync( async() => await endpoint.UpdateAccountSettingsAsync().ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); }
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); }
public async Task UpdateAccountSettingsAsync_OAuth2Null_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new AccountEndpoint(client); await endpoint.UpdateAccountSettingsAsync(); }