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 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 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 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); }
public void RewardPoints_Gold_Withdrawal() { // Arrange IAccount testAccount = AccountFactory.CreateAccount(AccountType.Gold); // Act testAccount.AddTransaction(4000M, "deposit"); testAccount.AddTransaction(4000M, "deposit"); testAccount.AddTransaction(-1000M, "withdrawal"); int points = testAccount.RewardPoints; // Assert Assert.AreEqual(points, 800 + 2 + 800); }
/// <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 DepositToAccountBalance() { // Arrange IAccount testAccount = AccountFactory.CreateAccount(AccountType.Silver); // Act testAccount.AddTransaction(+123.45M); decimal balance = testAccount.Balance; // Assert Assert.AreEqual(balance, +123.45M); }
/// <summary> /// withdrawal the given account into the account named /// /// Need to check for incoming negative amount, because it will be treated as /// as withdrawal and this should not be allowed, the user should use the deposit button /// /// </summary> /// <param name="accountName"></param> /// <param name="amount"></param> public void Withdrawal(string accountName, decimal amount) { IAccount acc = FindAccount(accountName); // check to make sure that the final amount isn't going to be a positive amount, because // it will signfy a deposit instead of a withdrawal if (amount > 0) { // for withdrawal, subtract amount acc.AddTransaction(-1 * amount, "withdrawal"); } }
/// <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) { /* * if(amount > 0) * { * IAccount acc = FindAccount(accountName); * acc.AddTransaction(amount); * } */ IAccount acc = FindAccount(accountName); acc.AddTransaction(amount, "deposit"); }
private void AddTransaction() { string name = CommandLine.EnterColleagueName(); IAccount account = null; account = AccountManager.AccountList.Find(s => s.Name.Equals(name)); // Verifies that the colleague exists. if (account == null) { CommandLine.ColleagueNotExist(); return; } string amount = CommandLine.EnterAmount(); // Verifies that the entered amount is in the correct format. if (!Validator.MoneyCheck(amount)) { CommandLine.InvalidMoneyFormat(); return; } decimal value = Convert.ToDecimal(amount); string dateString = CommandLine.EnterTransactionDate(); // Verifies that the entered string resembles a valid date. if (!Validator.DateCheck(dateString)) { CommandLine.InvalidDateFormat(); return; } DateTime date = Convert.ToDateTime(dateString); string purpose = CommandLine.EnterPurpose(); // Creates a transaction and adds it to the account. ITransaction trans = new TransactionImplementation(value, date, purpose); account.AddTransaction(trans); CommandLine.TransactionSuccess(account.Name, trans.ToString()); }
/// <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); }