public string AddAccount(string accountType, SecureString idPerson, decimal balance, float interestRate, SecureString Iban) { IAccount account = null; if (this.accountRepository.FindByIdentification(Iban)) { throw new Exception("Iban already exist!"); } //IPerson person = CheckIfPersonExistByID(idPerson); accountType = accountType.ToLower(); if (accountType == "checkingaccount") { account = new CheckingAccount(this.person, balance, interestRate, Iban); } else if (accountType == "childsavingsaccount") { account = new ChildSavingsAccount(this.person, balance, interestRate, Iban); } else if (accountType == "retirmentaccount") { account = new RetirmentAccount(this.person, balance, interestRate, Iban); } else { throw new ArgumentException("Account type is not valid"); } this.accountRepository.Add(account); return($"Successfully added {accountType}."); }
public void ChindAccountInvalidDeposit(int deposit) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 100, DateTime.Now.AddYears(-10), 213231, new List <Transaction>() { new Transaction(DateTime.Now.AddDays(-1), 5900, "asd", "asd") }, "010400-9995", 7); Assert.ThrowsException <ArgumentException>(() => acc.Deposit(deposit)); }
public void ChindAccountInvalidWithdrawLocked(string value, int years) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 100, DateTime.Now.AddYears(-10), 213231, new List <Transaction>(), value, years); Assert.ThrowsException <Exception>(() => acc.Withdraw(10)); }
public void ChindAccountWithdraw(string value, int years) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 1234, DateTime.Now.AddYears(-10), 213231, new List <Transaction>(), value, years); acc.Withdraw(10); }
public void ChindAccountCanBeWithdrawnFrom(string value, int years) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 1234, DateTime.Now, 213231, new List <Transaction>(), value, years); Assert.IsTrue(acc.CanBeWithdrawedFrom().Date == DateTime.Now.AddYears(years).Date); }
public void ChindAccountInitializationValidYearsLocked(string value, int years) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 1234, DateTime.Now, 213231, new List <Transaction>(), value, years); }
public void ChindAccountInitializationInvalidYearsLocked(string value, int years) { ChildSavingsAccount acc = null; Assert.ThrowsException <ArgumentException>(() => acc = new ChildSavingsAccount("1234 123455", 1234, DateTime.Now, 213231, new List <Transaction>(), value, years)); }
public void ChindAccountInitializationValidSsn(string value) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 1234, DateTime.Now, 213231, new List <Transaction>(), value, 7); }
public void ChindAccountInvalidDepositExceedAccountLimit(int deposit) { ChildSavingsAccount acc = new ChildSavingsAccount("1234 123455", 71000, DateTime.Now.AddYears(-10), 0, new List <Transaction>(), "010400-9995", 7); Assert.ThrowsException <ArgumentException>(() => acc.Deposit(deposit)); }