public void AskCredit_Success() { IClientManager clientManager = new ClientManager(); FinanceManager financeManager = new FinanceManager(clientManager, new EmailSenderMock()); ShoppingClient.Clients.Clear(); clientManager.RegisterUser("Marko", "Sinisic", "*****@*****.**", "markos123", "Novi Sad", new DateTime(1990, 5, 25), new List <IAccount>()); IClient client = ShoppingClient.Clients[0]; financeManager.CreateAccount("f231rf34f34f3f4", new Bank(), 10000, 0, true); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; client.ListOfAccounts.Add(account); financeManager.CreateBank("Raiffeisen", "Cara Lazara 55", new List <ICredit>(), "din", new List <IAccount>() { account }, 1000, 100000, 100); IBank bank = FinantialDB.Banks.Values.ToList()[0]; financeManager.CreateCredit("kredit", 0.05, FinantialDB.Currency["EUR"], bank, 10); ICredit credit = FinantialDB.Credits.Values.ToList()[0]; bank.ListOfCredits.Add(credit); financeManager.AskCredit(client.ID, credit.ID, 20, 50000); Assert.IsTrue(account.CreditPayment > 0); }
public void AskCredit_AmountExceeded() { IClientManager clientManager = new ClientManager(); FinanceManager financeManager = new FinanceManager(clientManager, new EmailSenderMock()); ShoppingClient.Clients.Clear(); clientManager.RegisterUser("Marko", "Sinisic", "*****@*****.**", "markos123", "Novi Sad", new DateTime(1990, 5, 25), new List <IAccount>()); IClient client = ShoppingClient.Clients[0]; financeManager.CreateAccount("f231rf34f34f3f4", new Bank(), 10000, 0, false); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; financeManager.CreateBank("Raiffeisen", "Cara Lazara 55", new List <ICredit>(), "din", new List <IAccount>() { account }, 1000, 10000, 100); IBank bank = FinantialDB.Banks.Values.ToList()[0]; financeManager.CreateCredit("kredit", 0.05, FinantialDB.Currency["EUR"], bank, 10); ICredit credit = FinantialDB.Credits.Values.ToList()[0]; bank.ListOfCredits.Add(credit); Assert.Throws <Exception>(() => financeManager.AskCredit(client.ID, credit.ID, 123, 50000), "Credit amount exceeds bank's maximum credit amount."); }
public void CreateBank_InvalidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Banks.Clear(); Assert.Throws <ArgumentNullException>(() => financeManager.CreateBank("", "Narodnog fronta 23", null, "odi", new List <IAccount>(), 1000, 100000, 2)); }
public void CreateBank_ValidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Banks.Clear(); financeManager.CreateBank("UniCredit", "Narodnog fronta 23", new List <ICredit>(), "odi", new List <IAccount>(), 1000, 100000, 2); Assert.IsTrue(FinantialDB.Banks.Count == 1); }