Пример #1
0
        public async Task GetTransactionsOneAccount()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("TransactionsOneAccount.json", HttpStatusCode.OK, HttpMethod.Post, "connect/get");
            IPlaidClient       testClient = this.GetPlaidClient(httpClient);
            TransactionResult  result     = await testClient.GetTransactionsAsync(new AccessToken("test_wells"), accountId : "QPO8Jo8vdDHMepg41PBwckXm4KdK1yUdmXOwK");

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsError);
            Assert.IsNotNull(result.Accounts);
            Assert.IsNotNull(result.Transactions);

            Assert.AreEqual(4, result.Accounts.Count);
            Assert.AreEqual(2, result.Transactions.Count);
        }
Пример #2
0
        public async Task GetPendingTransactions()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("PendingTransactions.json", HttpStatusCode.OK, HttpMethod.Post, "connect/get");
            IPlaidClient       testClient = this.GetPlaidClient(httpClient);
            TransactionResult  result     = await testClient.GetTransactionsAsync(new AccessToken("test_wells"), true);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsError);
            Assert.IsNotNull(result.Accounts);
            Assert.IsNotNull(result.Transactions);

            Assert.AreEqual(4, result.Accounts.Count);
            Assert.AreEqual(16, result.Transactions.Count);
        }
Пример #3
0
        public async Task GetTransactionsSuccess()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("AuthUserUsBank.json", HttpStatusCode.OK, HttpMethod.Post, "connect/get");
            IPlaidClient       testClient = this.GetPlaidClient(httpClient);

            TransactionResult result = await testClient.GetTransactionsAsync(new AccessToken("test_wells"));

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsError);
            Assert.IsNotNull(result.Accounts);
            Assert.IsNotNull(result.Transactions);

            Assert.AreEqual(4, result.Accounts.Count);
            Assert.AreEqual(16, result.Transactions.Count);

            Account account = result.Accounts[0];

            Assert.AreEqual("QPO8Jo8vdDHMepg41PBwckXm4KdK1yUdmXOwK", account.Id);
            Assert.AreEqual("KdDjmojBERUKx3JkDd9RuxA5EvejA4SENO4AA", account.ItemId);
            Assert.AreEqual("eJXpMzpR65FP4RYno6rzuA7OZjd9n3Hna0RYa", account.UserId);
            Assert.AreEqual(1203.42, account.AvailableBalance);
            Assert.AreEqual(1274.93, account.CurrentBalance);
            Assert.AreEqual(new InstitutionType("fake_institution"), account.InstitutionType);
            Assert.AreEqual(AccountType.Depository, account.AccountType);
            Assert.AreEqual(AccountSubType.Savings, account.AccountSubtype);
            Assert.IsNotNull(account.Metadata);
            Assert.AreEqual("Plaid Savings", account.Metadata["name"]);
            Assert.AreEqual("9606", account.Metadata["number"]);

            Transaction transaction = result.Transactions[0];

            Assert.AreEqual("XARE85EJqKsjxLp6XR8ocg8VakrkXpTXmRdOo", transaction.AccountId);
            Assert.AreEqual(200, transaction.Amount);
            Assert.AreEqual(new DateTimeOffset(2014, 7, 21, 0, 0, 0, TimeSpan.Zero), transaction.Date);
            Assert.AreEqual("ATM Withdrawal", transaction.Name);

            Assert.IsNotNull(transaction.Location);
            Assert.AreEqual("San Francisco", transaction.Location.City);
            Assert.AreEqual("CA", transaction.Location.State);
            Assert.IsNull(transaction.Location.Latitude);
            Assert.IsNull(transaction.Location.Longitude);

            Assert.AreEqual(false, transaction.IsPending);
            Assert.IsNotNull(transaction.Categories);
            Assert.AreEqual(3, transaction.Categories.Count);
            Assert.AreEqual("21012002", transaction.CategoryId);
        }
Пример #4
0
        public async Task GetTransactionsError()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("BadAccessToken.json", HttpStatusCode.Unauthorized, HttpMethod.Post, "connect/get");
            IPlaidClient       testClient = this.GetPlaidClient(httpClient);
            TransactionResult  result     = await testClient.GetTransactionsAsync(new AccessToken("test_bad"));

            Assert.IsNotNull(result);
            Assert.IsTrue(result.IsError);

            Assert.IsNotNull(result.Exception);
            Assert.AreEqual((int)HttpStatusCode.Unauthorized, result.Exception.HttpStatusCode);
            Assert.AreEqual(ErrorCode.BadAccessToken, result.Exception.ErrorCode);
            Assert.IsFalse(string.IsNullOrWhiteSpace(result.Exception.Message));
            Assert.IsFalse(string.IsNullOrWhiteSpace(result.Exception.Resolution));

            Assert.IsNull(result.Accounts);
            Assert.IsNull(result.Transactions);
        }
Пример #5
0
        public async Task GetTransactionsEndDate()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("TransactionsEndDate.json", HttpStatusCode.OK, HttpMethod.Post, "connect/get");
            IPlaidClient       testClient = this.GetPlaidClient(httpClient);
            DateTimeOffset     endDate    = new DateTimeOffset(2014, 4, 1, 0, 0, 0, TimeSpan.Zero);

            TransactionResult result = await testClient.GetTransactionsAsync(new AccessToken("test_wells"), null, null, null, endDate);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsError);
            Assert.IsNotNull(result.Accounts);
            Assert.IsNotNull(result.Transactions);

            Assert.AreEqual(4, result.Accounts.Count);
            Assert.AreEqual(1, result.Transactions.Count);

            foreach (Transaction t in result.Transactions)
            {
                Assert.IsTrue(t.Date < endDate);
            }
        }