Esempio n. 1
0
        public void AddFunds_InvalidTestPravnoLiceRacun(double amount)
        {
            IFinanceManager financeManager = new FinanceManagerMock();
            IClientManager  clientManager  = new ClientManager(financeManager, new EmailSenderMock());
            IClient         client         = new PravnoLice("dasdfasdf", "r34f324f", "Novi Sad", "*****@*****.**", DateTime.Now, new List <IAccount>());

            Assert.Throws <Exception>(() => clientManager.AddFunds(client, Guid.NewGuid(), amount, new CurrencyMock()), "Amount has to be greater than 10000.");
        }
Esempio n. 2
0
        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 AddFunds_ConvertReceivedCall_Successful()
        {
            var financeManager = Substitute.For <IFinanceManager>();
            var clientManager  = new ClientManager(clientList, financeManager);
            var client         = clientManager.GetClientById(new Guid("00000000-0000-0000-0000-400000000002"));
            var account        = new Account(DateTime.Now, new Bank("bnk", "addr", "*****@*****.**", "111-111"), 22);

            account.Credit = new Credit(200, 500, 0.15, 2, 7, true);
            client.Accounts.Add(account);
            var logger      = new FakeLogger();
            var emailSender = new FakeEmailSender();
            var currency    = new DolarCurrency(1.05);

            clientManager.AddFunds(client, 20000, currency, emailSender, logger);

            clientManager.FinanceManager.Received().Convert(currency, 20000);
        }
Esempio n. 4
0
        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 AccountPayment_AmountLessOrEqualZero_ThrowException()
        {
            var financeManager = Substitute.For <IFinanceManager>();

            financeManager
            .When(x => x.AccountPayment(Arg.Any <Guid>(),
                                        Arg.Is <double>(y => y <= 0)))
            .Do(x => { throw new ArgumentOutOfRangeException("Amount cannot be smaller or equal than 0"); });
            var clientManager = new ClientManager(clientList, financeManager);

            var client  = new User("User", "SurUser", "Bulevar", "111-111", "*****@*****.**");
            var account = new Account(DateTime.Now, new Bank("bnk", "addr", "*****@*****.**", "111-111"), 22);

            client.Accounts.Add(account);
            var logger      = new FakeLogger();
            var emailSender = new FakeEmailSender();

            Assert.Throws <ArgumentOutOfRangeException>(() => clientManager.AddFunds(client, 0, new DinarCurrency(), emailSender, logger));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public void AddFunds_InvalidArgumentsTest()
        {
            IClientManager clientManager = new ClientManager();

            Assert.Throws <ArgumentNullException>(() => clientManager.AddFunds(null, Guid.NewGuid(), 123, null));
        }