public void OverdraftAccountConstructorTest() { OverdraftAccount target = new OverdraftAccount(); Assert.IsNotNull(target); //Assert.Inconclusive("TODO: Implement code to verify target"); }
static void Main() { SavingsAccount saving = new SavingsAccount("0001", "S01A", 2000); Console.WriteLine(saving.ToString()); CurrentAccount current = new CurrentAccount("0002", "S02A", 2000); Console.WriteLine(current.ToString()); OverdraftAccount over1 = new OverdraftAccount("0003", "S03A", 2000); Console.WriteLine(over1.ToString()); OverdraftAccount over2 = new OverdraftAccount("0001", "S01A", -2000); Console.WriteLine(over2.ToString()); Console.WriteLine(); BankBranch branch = new BankBranch("TIAN TIAN"); branch.AddAccount(saving); branch.AddAccount(current); branch.AddAccount(over1); branch.AddAccount(over2); Console.WriteLine("Print all accounts: "); branch.PrintAccounts(); Console.WriteLine(); Console.WriteLine("Print total deposit:{0}", branch.TotalDeposits()); Console.WriteLine("Print total interestpaid:{0}", branch.TotalInterestPaid()); Console.WriteLine("Print total interestearned:{0}", branch.TotalInterestEarned()); Console.WriteLine(); Console.WriteLine("Print all customers: "); branch.PrintCustomers(); }
public void OverdraftAccount_InterestCalc_Overdraft() { decimal initalBalance = -100; decimal expected = -103.25M; decimal overdraftLimit = 10000; PrivateCustomer pc = new PrivateCustomer() { CustomerID = Guid.NewGuid(), ContactInformation = new Contact() { FirstName = "test", LastName = "test", Address = "test", Email = "test", PhoneNumbers = new List <string>() { "123-122" } } }; OverdraftAccount ba = new OverdraftAccount(initalBalance, new List <PrivateCustomer>() { pc }, overdraftLimit); ba.CalculateInterest(); decimal actual = ba.Balance; Assert.AreEqual(expected, actual); }
public void OverdraftAccount_Debit_ExceedLimit() { decimal debitAmount = 250; decimal initalBalance = 100; decimal expected = 100; decimal overdraftLimit = 100; PrivateCustomer pc = new PrivateCustomer() { CustomerID = Guid.NewGuid(), ContactInformation = new Contact() { FirstName = "test", LastName = "test", Address = "test", Email = "test", PhoneNumbers = new List <string>() { "123-122" } } }; OverdraftAccount ba = new OverdraftAccount(initalBalance, new List <PrivateCustomer>() { pc }, overdraftLimit); ba.Debit(debitAmount); decimal actual = ba.Balance; Assert.AreEqual(expected, actual); }
public void OverdraftAccountGetMoneyFull() { OverdraftAccount acc = new OverdraftAccount(new TimeSpan(99, 99, 99), 0.2, 100, 100); acc.addMoney(1000); Assert.AreEqual(13, acc.getMoney(13)); }
public IActionResult CreateNewOverdraft(NewOverdraftAccountViewModel vm) { if (!vm.CustomerList.Any(pc => pc.IsSelected)) { vm.DisplayMessage = "Must select at least one account owner"; return(View(vm)); } else if (vm.InitialBalance < 0) { vm.DisplayMessage = "Please input a positive sum for initial balance"; return(View(vm)); } else if (vm.OverdraftLimit < 0) { vm.DisplayMessage = "Please input a positive sum for overdraft limit"; return(View(vm)); } else { //get bank data, then save account to file and send back to start page var bank = Utility.Utility.GetBankData(_env.WebRootPath); var selectedOwners = vm.CustomerList.Where(pc => pc.IsSelected); var owners = new List <PrivateCustomer>(); foreach (var owner in selectedOwners) { owners.Add(bank.PrivateCustomers.Single(pc => pc.CustomerID == owner.CustomerID)); } var account = new OverdraftAccount(vm.InitialBalance, owners, vm.OverdraftLimit); bank.OverdraftAccounts.Add(account); //now save to file Utility.Utility.SaveBankData(_env.WebRootPath, bank); return(RedirectToAction("Index", "Home", new { message = Message.CreatePrivateAccountSuccess })); } }
public void OverdraftAccountGetMoneyBalance() { OverdraftAccount acc = new OverdraftAccount(new TimeSpan(99, 99, 99), 0.2, 100, 100); acc.addMoney(1000); acc.getMoney(100); Assert.AreEqual(900, acc.checkBalance()); }
public void OverdraftAccountConstructorTest1() { double bal = 0F; // TODO: Initialize to an appropriate value DateTime date = DateTime.Now; // TODO: Initialize to an appropriate value double int_rate = 0.05; // TODO: Initialize to an appropriate value DateTime last_acc_date = date; // TODO: Initialize to an appropriate value OverdraftAccount target = new OverdraftAccount(bal, date, int_rate, last_acc_date); Assert.IsNotNull(target); //Assert.Inconclusive("TODO: Implement code to verify target"); }
public void CheckBalanceTest1() { OverdraftAccount target = new OverdraftAccount(1000.0, new DateTime(2012, 7, 10), 0.05, DateTime.Now.AddDays(-30)); // TODO: Initialize to an appropriate value double expected = 0; // TODO: Initialize to an appropriate value double actual; target.Withdraw(1000, DateTime.Now); actual = target.CheckBalance(); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
private static void ProtectedAccessExample() { OverdraftAccount a = new OverdraftAccount(); Console.WriteLine("Pay in 50"); a.PayInFunds(50); if (a.WithdrawFunds(60)) { Console.WriteLine("Withdraw 60"); } Console.WriteLine("Account balance is: {0}", a.GetBalance()); }
private static void CallEnforceEcapsulation() { OverdraftAccount c = new OverdraftAccount(); c.PayInFunds(50); Console.WriteLine("Pay in 50"); c.PayInFunds(50); if (c.WithdrawFunds(10)) { Console.WriteLine("Withdraw 10"); } Console.WriteLine("Account balance is: {0}", c.GetBalance()); }
public void TestTakeMoneyPercent() { double balance = 1000; double takeMoney = 3000; double interest = 0.3; OverdraftAccount acc = new OverdraftAccount(balance, interest); acc.takeMoney(takeMoney); balance -= takeMoney; acc.takePercent(); if (balance < 0) { balance += balance * interest; } Assert.AreEqual(balance, acc.getBalance(), "Wrong takePercent Method"); }
public void Setup() { account = new OverdraftAccount(1, "Someone", correctPassword, balance); }
public void OverdraftAccountBalance() { OverdraftAccount acc = new OverdraftAccount(new TimeSpan(99, 99, 99), 0.2, 100, 100); Assert.AreEqual(0, acc.checkBalance()); }
public void OverdraftAccountCreate() { OverdraftAccount acc = new OverdraftAccount(new TimeSpan(99, 99, 99), 0.2, 100, 100); Assert.AreNotEqual(null, acc); }