public void SavingsAccount_Debit_InvalidAmount() { decimal debitAmount = -5; decimal initalBalance = 100; decimal expected = 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" } } }; BonusSavingsAccount ba = new BonusSavingsAccount(new List <PrivateCustomer>() { pc }, initalBalance); ba.Debit(debitAmount); decimal actual = ba.Balance; Assert.AreEqual(expected, actual); }
public void SavingsAccount_InterestCalc_LastDebitMoreThanThirty() { decimal initalBalance = 100; decimal expected = 105.25M; PrivateCustomer pc = new PrivateCustomer() { CustomerID = Guid.NewGuid(), ContactInformation = new Contact() { FirstName = "test", LastName = "test", Address = "test", Email = "test", PhoneNumbers = new List <string>() { "123-122" } } }; BonusSavingsAccount ba = new BonusSavingsAccount(new List <PrivateCustomer>() { pc }, initalBalance); ba.LastDebit = default(DateTime); ba.CalculateInterest(); decimal actual = ba.Balance; Assert.AreEqual(expected, actual); }
public void SavingsAccount_ResetDebit() { decimal initalBalance = 100; DateTime expected = default(DateTime); PrivateCustomer pc = new PrivateCustomer() { CustomerID = Guid.NewGuid(), ContactInformation = new Contact() { FirstName = "test", LastName = "test", Address = "test", Email = "test", PhoneNumbers = new List <string>() { "123-122" } } }; BonusSavingsAccount ba = new BonusSavingsAccount(new List <PrivateCustomer>() { pc }, initalBalance); ba.ResetDebitCounter(); DateTime actual = ba.LastDebit; Assert.AreEqual(expected, actual); }
public IActionResult CreateNewBonus(NewBonusSavingsAccountViewModel 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 { //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 BonusSavingsAccount(owners, vm.InitialBalance); bank.BonusSavingsAccounts.Add(account); //now save to file Utility.Utility.SaveBankData(_env.WebRootPath, bank); return(RedirectToAction("Index", "Home", new { message = Message.CreatePrivateAccountSuccess })); } }