/// <summary> /// withdrawal the given account into the account named /// </summary> /// <param name="accountName"></param> /// <param name="amount"></param> public void Withdrawal(string accountName, decimal amount) { iAccount acc = FindAccount(accountName); // for withdrawal, subtract amount acc.AddTransaction(-1 * amount); }
public void CreateAccountSetsBalanceToZero() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Silver); // Act decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, 0.00M); }
public void DepositToAccountBalance() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(+123.45M); decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, +123.45M); }
public void RewardPoints_Silver_Deposit() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(1000M); testAccount.AddTransaction(1000M); int points = testAccount.RewardPoints; // Assert Assert.AreEqual(points, 200); }
public void NegativeBalanceAllowed() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(+200M); testAccount.AddTransaction(-500M); decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, -300M); }
public void WithdrawalToAccountBalance() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(+200M); testAccount.AddTransaction(-100M); decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, +100M); }
public void RewardPoints_Platinum_Deposit() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Platinum); // Act testAccount.AddTransaction(4000M); testAccount.AddTransaction(4000M); int points = testAccount.RewardPoints; // Assert Assert.AreEqual(points, 2000 + 4 + 2000); }
public void RewardPoint_Gold_Deposit() { // Arrange iAccount testAccount = accountFactory.CreateAccount(AccountType.Gold); // Act testAccount.AddTransaction(4000M); testAccount.AddTransaction(4000M); int points = testAccount.RewardPoints; // Assert Assert.AreEqual(points, 800 + 2 + 800); }
/// <summary> /// Factory method to create the correct type of account /// given the account type. /// </summary> /// <param name="type"></param> /// <returns></returns> public static iAccount CreateAccount(AccountType type) { iAccount account = null; switch (type) { case AccountType.Silver: account = new SilverAccount(); break; case AccountType.Gold: account = new GoldAccount(); break; case AccountType.Platinum: account = new PlatinumAccount(); break; } return(account); }
/// <summary> /// deposit the given account into the account named /// </summary> /// <param name="accountName"></param> /// <param name="amount"></param> public void Deposit(string accountName, decimal amount) { iAccount acc = FindAccount(accountName); acc.AddTransaction(amount); }
/// <summary> /// find the reward points of the given account /// </summary> /// <param name="accountName"></param> /// <returns></returns> public int GetRewardPoints(string accountName) { iAccount acc = FindAccount(accountName); return(acc.RewardPoints); }
/// <summary> /// find the balance of the given account /// </summary> /// <param name="accountName"></param> /// <returns></returns> public decimal GetAccountBalance(string accountName) { iAccount acc = FindAccount(accountName); return(acc.Balance); }
/// <summary> /// create a new account /// </summary> /// <param name="accountName"></param> /// <param name="accountType"></param> public void CreateAccount(string accountName, AccountType accountType) { iAccount newAccount = accountFactory.CreateAccount(accountType); accountsDictionary.Add(accountName, newAccount); }