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 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 CreateAccount_InvalidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); Assert.Throws <ArgumentNullException>(() => financeManager.CreateAccount("412341234", null, 34534, 600, true)); }
public void CreateAccount_ValidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); Assert.IsTrue(FinantialDB.Accounts.Count == 1); }
public void CheckBalance_InvalidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; Assert.Throws <KeyNotFoundException>(() => financeManager.CheckBalance(Guid.NewGuid())); }
public void CreateTransaction_ValidTest(int year, int month, int day, int rating, string transcationTypeKey) { IEmailSender emailSender = Substitute.For <IEmailSender>(); IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(); ISalesManager salesManager = new SalesManager(); ShoppingClient.Clients.Clear(); ShoppingOffers.Offers.Clear(); clientManager.RegisterUser("Pera", "Peric", "*****@*****.**", "peraPeric123", "Novi Sad", new DateTime(1992, 5, 6), new List <IAccount>()); clientManager.RegisterOrg("Prodavnica", "q234ffsad", "Novi Sad", "*****@*****.**", new DateTime(2010, 1, 1), new List <IAccount>()); IClient client = ShoppingClient.Clients.FirstOrDefault(x => x is FizickoLice); IClient company = ShoppingClient.Clients.FirstOrDefault(x => x is PravnoLice); IProduct product = new Product("Product", "Description", 3000, 1); salesManager.CreateOffer(company, new List <IProduct>() { product }, new List <ITransport>()); financeManager.CreateAccount("41234123453425", new Bank(), 100000, 0, false); financeManager.CreateAccount("456345634567456", new Bank(), 100000, 0, false); IAccount customerAccount = FinantialDB.Accounts.Values.ToList()[0]; IAccount companyAccount = FinantialDB.Accounts.Values.ToList()[1]; client.ListOfAccounts.Add(customerAccount); customerAccount.Balance = 1000000; company.ListOfAccounts.Add(companyAccount); companyAccount.Balance = 2000000; IOffer offer = ShoppingOffers.Offers.Values.ToList()[0]; offer.SubmitionDate = new DateTime(year, month, day); ITransactionManager transactionManager = new TransactionManager(clientManager, salesManager, financeManager, emailSender); ITransactionType transactionType = ShoppingTransaction.TransactionTypes[transcationTypeKey]; transactionManager.CreateTransaction(client.ID, company.ID, offer.ID, transactionType.ID, rating); Assert.IsTrue(client.ListOfBuyingTransaction.Count == 1); Assert.IsTrue(company.ListOfSellingTransaction.Count == 1); }
public void CreditPayment_InvalidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; double oldCredit = account.CreditPayment; Assert.Throws <KeyNotFoundException>(() => financeManager.CreditPayment(Guid.NewGuid(), 100)); }
public void AddFunds_InvalidTestClientDb(double amount) { IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(financeManager, new EmailSenderMock()); financeManager.CreateAccount("6345634563456", new Bank(), 1500, 0, true); var account = FinantialDB.Accounts.Values.ToList()[0]; IClient client = new PravnoLice("dasdfasdf", "r34f324f", "Novi Sad", "*****@*****.**", DateTime.Now, new List <IAccount>()); ICurrency currency = FinantialDB.Currency["EUR"]; double oldAmount = account.CreditPayment; Assert.Throws <KeyNotFoundException>(() => clientManager.AddFunds(client, account.ID, amount, currency), "Account not found in clients database."); }
public void CreditPayment_ValidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; double oldCredit = account.CreditPayment; financeManager.CreditPayment(account.ID, 100); Assert.IsTrue(account.CreditPayment == oldCredit - 100 * 1.05); }
public void AddFunds_ValidTestFizickoLiceKredit(double amount) { IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(financeManager, new EmailSenderMock()); financeManager.CreateAccount("6345634563456", new Bank(), 1500, 0, true); var account = FinantialDB.Accounts.Values.ToList()[0]; IClient client = new PravnoLice("dasdfasdf", "r34f324f", "Novi Sad", "*****@*****.**", DateTime.Now, new List <IAccount>() { account }); ICurrency currency = FinantialDB.Currency["EUR"]; double oldAmount = account.CreditPayment; clientManager.AddFunds(client, account.ID, amount, currency); Assert.IsTrue(oldAmount > account.CreditPayment); }
public void CheckBalance_ValidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); IAccount account = FinantialDB.Accounts.Values.ToList()[0]; account.Balance = 500; double balance = account.Balance; double balance2 = financeManager.CheckBalance(account.ID); Assert.AreEqual(balance, balance2); }
public void GetAccountById_ValidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); Guid targetId = FinantialDB.Accounts.Values.ToList()[0].ID; IAccount account = financeManager.GetAccountByID(targetId); Assert.IsTrue(account.ID == targetId); }
public void AddFunds_ValidTestFizickoLiceRacun(double amount) { IFinanceManager financeManager = new FinanceManager(); IClientManager clientManager = new ClientManager(financeManager, new EmailSenderMock()); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("6345634563456", new Bank(), 1500, 0, false); var account = FinantialDB.Accounts.Values.ToList()[0]; IClient client = new FizickoLice("Marko", "Markovic", "*****@*****.**", "marko123", DateTime.Now, "Novi Sad", new List <IAccount>() { account }); ICurrency currency = FinantialDB.Currency["EUR"]; double oldAmount = account.Balance; clientManager.AddFunds(client, account.ID, amount, currency); Assert.AreEqual(oldAmount + amount * currency.Value, account.Balance); }
public void GetAccountById_InvalidTest() { FinanceManager financeManager = new FinanceManager(); FinantialDB.Accounts.Clear(); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); financeManager.CreateAccount("412341234", new Bank(), 34534, 600, true); Guid targetId = FinantialDB.Accounts.Values.ToList()[0].ID; Assert.Throws <KeyNotFoundException>(() => financeManager.GetAccountByID(Guid.NewGuid())); }