示例#1
0
        public void CreateCredit_InvalidTest()
        {
            FinanceManager financeManager = new FinanceManager();

            FinantialDB.Credits.Clear();
            Assert.Throws <ArgumentNullException>(() => financeManager.CreateCredit("Dobar kredit", 0.04, null, null, 10));
        }
示例#2
0
        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);
        }
示例#3
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.");
        }
示例#4
0
        public void CreateCredit_ValidTest()
        {
            FinanceManager financeManager = new FinanceManager();

            FinantialDB.Credits.Clear();
            financeManager.CreateCredit("Dobar kredit", 0.04, new Currency(), new Bank(), 10);
            Assert.IsTrue(FinantialDB.Credits.Count == 1);
        }