public void DeleteBankAccountSuccessfully()
        {
            var repo = new BankAccountRepository();
            var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new BankAccount
            {
                UserId = userId,
                Active = true,
                Bank = new Bank
                {
                    BankName = "Test bank, inc",
                    AccountName = "Test account",
                    AccountNumber = "8123456789",
                    AccountType = "savings",
                    Country = "AUS",
                    HolderType = "personal",
                    RoutingNumber = "123456"
                }
            };
            var createdAccount = repo.CreateBankAccount(account);
            Assert.IsTrue(createdAccount.Active);
            var result = repo.DeleteBankAccount(createdAccount.Id);

            Assert.IsTrue(result);

            var gotAccount = repo.GetBankAccountById(createdAccount.Id);
            Assert.IsFalse(gotAccount.Active);
        }
예제 #2
0
        public void CreateBankAccountSuccessfully()
        {
            var content = File.ReadAllText("../../Fixtures/bank_account_create.json");

            var client = GetMockClient(content);
            var repo = new BankAccountRepository(client.Object);

            const string userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
            var account = new BankAccount
            {
                UserId = userId,
                Active = true,
                Bank = new Bank
                {
                    BankName = "Test bank, inc",
                    AccountName = "Test account",
                    AccountNumber = "8123456789",
                    AccountType = "savings",
                    Country = "AUS",
                    HolderType = "personal",
                    RoutingNumber = "123456"
                }
            };
            var createdAccount = repo.CreateBankAccount(account);
            client.VerifyAll();
            Assert.IsNotNull(createdAccount);
            Assert.IsNotNull(createdAccount.Id);
            Assert.AreEqual("AUD", createdAccount.Currency); // It seems that currency is determined by country
            Assert.IsNotNull(createdAccount.CreatedAt);
            Assert.IsNotNull(createdAccount.UpdatedAt);
            Assert.AreEqual("XXX789", createdAccount.Bank.AccountNumber); //Account number is masked
        }
 public void CreateBankAccountSuccessfully()
 {
     var repo = new BankAccountRepository();
     var userId = "ec9bf096-c505-4bef-87f6-18822b9dbf2c"; //some user created before
     var account = new BankAccount
     {
         UserId = userId,
         Active = true,
         Bank = new Bank
         {
             BankName = "Test bank, inc",
             AccountName = "Test account",
             AccountNumber = "8123456789",
             AccountType = "savings",
             Country = "AUS",
             HolderType = "personal",
             RoutingNumber = "123456"
         }
     };
     var createdAccount = repo.CreateBankAccount(account);
     Assert.IsNotNull(createdAccount);
     Assert.IsNotNull(createdAccount.Id);
     Assert.AreEqual("AUD", createdAccount.Currency); // It seems that currency is determined by country
     Assert.IsNotNull(createdAccount.CreatedAt);
     Assert.IsNotNull(createdAccount.UpdatedAt);
     Assert.AreEqual("XXXXXXX789", createdAccount.Bank.AccountNumber); //Account number is masked
 }
        public BankAccount CreateBankAccount(BankAccount bankAccount)
        {
            var request = new RestRequest("/bank_accounts", Method.POST);
            request.AddParameter("user_id", bankAccount.UserId);
            request.AddParameter("bank_name", bankAccount.Bank.BankName);
            request.AddParameter("account_name", bankAccount.Bank.AccountName);
            request.AddParameter("routing_number", bankAccount.Bank.RoutingNumber);
            request.AddParameter("account_number", bankAccount.Bank.AccountNumber);
            request.AddParameter("account_type", bankAccount.Bank.AccountType);
            request.AddParameter("holder_type", bankAccount.Bank.HolderType);
            request.AddParameter("country", bankAccount.Bank.Country);

            var response = SendRequest(Client, request);
            return JsonConvert.DeserializeObject<IDictionary<string, BankAccount>>(response.Content).Values.First();
        }