public void CreateBankDepositAccount_FailsDuplicateShortName() { BankDepositAccount account = services.CreateBankDepositAccount("myBANK_13", "name", "bankname", "001", "999-9", "R$", 1m); Assert.IsNotNull(account); services.CreateBankDepositAccount("myBANK_13", "name", "bankname", "001", "999-9", "R$", 1m); }
public BankDepositAccount CreateBankDepositAccount( string shortName, string name, string bankName, string bankAgencyId, string bankAccountId, string currency, decimal initialBalance) { if (string.IsNullOrEmpty(shortName)) { throw new ArgumentException("Parameter shortName cannot be null or empty"); } if (repository.Exists(shortName)) { throw new DuplicateInstanceException("Account", "ShortName"); } BankDepositAccount account = BankDepositAccount.Create( shortName, name, bankName, bankAgencyId, bankAccountId, currency, initialBalance); repository.Create(account); return(account); }
public void CreateAccount_ExistsSameInOtherRepositoryInstance() { BankDepositAccount account = BankDepositAccount.Create("XYZDEF", "abc", "abc", "001", "00099-9", "R$", 1m); repository.Create(account); Assert.IsTrue(repositoryAlternate.Exists(account.ShortName)); }
void IAccountRepository.Create(BankDepositAccount account) { if (accounts.ContainsKey(account.ShortName)) { throw new InvalidOperationException(); } accounts.Add(account.ShortName, account); }
public void Create(BankDepositAccount account) { ReadAccounts(); if (accounts.ContainsKey(account.ShortName)) throw new DuplicateInstanceException("Account", "ShortName"); accounts.Add(account.ShortName, account); WriteAccounts(); }
public void AccumulateBalance(BankDepositAccount account) { if (balances.ContainsKey(account.Currency)) { balances[account.Currency] += account.FinalBalance; } else { balances.Add(account.Currency, account.FinalBalance); } }
public void Update(BankDepositAccount account) { ReadAccounts(); if (!accounts.ContainsKey(account.ShortName)) throw new InvalidOperationException(); accounts[account.ShortName] = account; WriteAccounts(); }
void IAccountRepository.Update(BankDepositAccount account) { if (!accounts.ContainsKey(account.ShortName)) { throw new InvalidOperationException(); } accounts[account.ShortName] = account; }
public void CreateAccount_FetchSameWithOtherRepositoryInstance() { BankDepositAccount account = BankDepositAccount.Create("ABCDEF", "abc", "abc", "001", "00099-9", "R$", 1m); repository.Create(account); BankDepositAccount readAccount = repositoryAlternate.Fetch(account.ShortName); Assert.AreEqual(account, readAccount); }
public void ListAccounts_OneAccountRepo_OneAccountResult() { accounts.Clear(); BankDepositAccount account = services.CreateBankDepositAccount("myBANK_14", "name", "bankname", "001", "999-9", "R$", 1m); BankDepositAccount[] list = services.ListOfAccounts; Assert.IsNotNull(list); Assert.AreEqual(1, list.Length); Assert.AreEqual(account.ShortName, list[0].ShortName); }
public void Update(BankDepositAccount account) { ReadAccounts(); if (!accounts.ContainsKey(account.ShortName)) { throw new InvalidOperationException(); } accounts[account.ShortName] = account; WriteAccounts(); }
public void Create(BankDepositAccount account) { ReadAccounts(); if (accounts.ContainsKey(account.ShortName)) { throw new DuplicateInstanceException("Account", "ShortName"); } accounts.Add(account.ShortName, account); WriteAccounts(); }
public void AccumulateBalance(BankDepositAccount account) { if (balances.ContainsKey(account.Currency)) { balances[account.Currency] += account.FinalBalance; } else { balances.Add(account.Currency, account.FinalBalance); } }
public void CreateBankDepositAccount_SucceedNoDefaults() { BankDepositAccount account = services.CreateBankDepositAccount("myBANK_12", "name", "bankname", "001", "999-9", "R$", 1m); Assert.IsNotNull(account); Assert.AreEqual("MYBANK_12", account.ShortName); // uppercase Assert.AreEqual("name", account.Name); Assert.AreEqual("bankname", account.BankName); Assert.AreEqual("001", account.BankAgencyId); Assert.AreEqual("999-9", account.BankAccountId); Assert.AreEqual("R$", account.Currency); Assert.AreEqual(1m, account.InitialBalance); Assert.GreaterOrEqual(DateTime.Now, account.DateOfCreation); Assert.Less(DateTime.Now.AddMinutes(-5), account.DateOfCreation); }
public void CreateAccount_ListReturnsAtLeastIt_InOtherRepositoryInstance() { BankDepositAccount account = BankDepositAccount.Create("XYZWWW", "abc", "abc", "001", "00099-9", "R$", 1m); repository.Create(account); BankDepositAccount[] list = repositoryAlternate.FetchAll(); Assert.IsNotNull(list); Assert.IsNotEmpty(list); bool found = false; foreach (BankDepositAccount readAccount in list) { if (account.Equals(readAccount)) { found = true; break; } } Assert.IsTrue(found, "Account not found in read list"); }
void IAccountRepository.Update(BankDepositAccount account) { if (!accounts.ContainsKey(account.ShortName)) throw new InvalidOperationException(); accounts[account.ShortName] = account; }
void IAccountRepository.Create(BankDepositAccount account) { if (accounts.ContainsKey(account.ShortName)) throw new InvalidOperationException(); accounts.Add(account.ShortName, account); }