public async Task ExchangeTokenSuccess() { IHttpClientWrapper httpClient = this.GetMockHttpClient("TokenExchangeSuccess.json", HttpStatusCode.OK, HttpMethod.Post, "exchange_token"); IPlaidClient testClient = this.GetPlaidClient(httpClient); var result = await testClient.ExchangeBankTokenAsync("test_public_token", "test_account_id"); Assert.IsNotNull(result); Assert.IsFalse(result.IsError); Assert.IsNotNull(result.AccessToken); Assert.AreEqual("foobar_plaid_access_token", result.AccessToken.Value); Assert.AreEqual("foobar_stripe_bank_account_token", result.BankAccountToken); }
public async Task ExchangeTokenFailed() { IHttpClientWrapper httpClient = this.GetMockHttpClient("InvalidCredentials.json", HttpStatusCode.Unauthorized, HttpMethod.Post, "exchange_token"); IPlaidClient testClient = this.GetPlaidClient(httpClient); TokenExchangeResult result = await testClient.ExchangeBankTokenAsync("test_public_token", "test_account_id"); Assert.IsNull(result.AccessToken); Assert.IsNull(result.BankAccountToken); Assert.IsTrue(result.IsError); Assert.IsNotNull(result.Exception); Assert.AreEqual(401, result.Exception.HttpStatusCode); Assert.AreEqual(ErrorCode.InvalidCredentials, result.Exception.ErrorCode); Assert.IsFalse(string.IsNullOrWhiteSpace(result.Exception.Message)); Assert.IsFalse(string.IsNullOrWhiteSpace(result.Exception.Resolution)); }