Пример #1
0
        public void TestPasswordHash()
        {
            UnitTesting.SetupTesting();
            var      pass = "******";
            Customer c    = new Customer("user", pass);

            Assert.IsTrue(c.Login(pass));
            UnitTesting.EndTest();
        }
Пример #2
0
        public void TestAddDelete()
        {
            UnitTesting.SetupTesting();
            CreateCustomer();
            Task <bool> removeCustomer = Task.Run(() => Bank.RemoveCustomer());

            UnitTesting.AddInput("yes");
            Assert.IsTrue(removeCustomer.GetAwaiter().GetResult());
            UnitTesting.EndTest();
        }
Пример #3
0
        public void TestGetAccounts()
        {
            UnitTesting.SetupTesting();
            Customer c = new Customer("user", "pass");

            c.AddAccount(new CheckingAccount(1));
            c.AddAccount(new TermDeposit(2, 4000));
            c.AddAccount(new BusinessAccount(3));
            Assert.IsTrue(c.GetAccounts <IChecking>().Count == 2);
            UnitTesting.EndTest();
        }
Пример #4
0
        public void TestListAccountTypes()
        {
            UnitTesting.SetupTesting();
            List <string> l = Bank.ListAccountTypes <IAccount>();

            Assert.IsTrue(l.Contains("checking") && l.Contains("business") && l.Contains("loan") && l.Contains("cd"));
            Log.Debug("Part 1 complete");
            l = Bank.ListAccountTypes <IChecking>();
            Assert.IsTrue(l.Contains("checking") && l.Contains("business") && l.Count == 2);
            UnitTesting.EndTest();
        }
Пример #5
0
        public void TestCompoundInterest()
        {
            UnitTesting.SetupTesting();
            IAccount a = new CheckingAccount(3);

            a.Balance     = 5000;
            a.LastUpdated = a.LastUpdated.AddMonths(-1);
            a.CompoundInterest(.01M);
            Log.Debug("a.Balance:" + a.Balance);
            Assert.AreEqual(5000 + (5000M * .01M) / 12M, a.Balance);
            UnitTesting.EndTest();
        }
Пример #6
0
        public void TestNegativeGetDollarAmountFraction()
        {
            UnitTesting.SetupTesting();
            Task <decimal> getAmt = Task.Run(() => ConsoleUtil.GetDollarAmount());

            UnitTesting.AddInput("45.555");
            UnitTesting.AddInput("45.67");
            decimal res = getAmt.GetAwaiter().GetResult();

            Assert.AreEqual(45.67M, res);
            UnitTesting.EndTest();
        }
Пример #7
0
        public void TestGetPass()
        {
            UnitTesting.SetupTesting();
            int           minPassLen = 5;
            string        password   = "******";
            Task <string> getPass    = Task.Run(() => ConsoleUtil.GetPass(minPassLen));

            UnitTesting.AddInput("p\n");
            UnitTesting.AddInput(password + "\n");
            string res = getPass.GetAwaiter().GetResult();

            Assert.IsTrue(password == res);
            UnitTesting.EndTest();
        }
Пример #8
0
        public void TestFormatTransactions()
        {
            UnitTesting.SetupTesting();
            //Customer c = new Customer("name", "pass");
            CheckingAccount ca = new CheckingAccount(3);

            //c.AddAccount(ca);
            ca.Deposit(45.55M);
            ca.Deposit(67);
            ca.Withdraw(56);
            ca.Deposit(4.50M);
            Log.Information("Format transactions test:\n" + Transaction.FormatTransactions(ca.Transactions));
            Assert.IsTrue(true);
            UnitTesting.EndTest();
        }
Пример #9
0
        public void TestLogin()
        {
            UnitTesting.SetupTesting();
            CreateCustomer();
            Task logoutCustomer = Task.Run(() => Bank.MainMenu());

            UnitTesting.AddInput("logout");
            logoutCustomer.GetAwaiter().GetResult();
            Task <bool> loginCustomer = Task.Run(() => Bank.Login());

            UnitTesting.AddInput("login");
            UnitTesting.AddInput("user");
            UnitTesting.AddInput("password");
            Assert.IsTrue(loginCustomer.GetAwaiter().GetResult());
            UnitTesting.EndTest();
        }
Пример #10
0
        public void TestAddDepositDelete()
        {
            UnitTesting.SetupTesting();
            Regex re = new Regex(@"\$45\.55");

            UnitTesting.AddWatch(re);
            CreateCustomer();
            Task deposit = Task.Run(() => Bank.MainMenu());

            UnitTesting.AddInput("view");
            UnitTesting.AddInput("deposit");
            UnitTesting.AddInput("45.55");
            UnitTesting.AddInput("return");
            UnitTesting.AddInput("close");
            UnitTesting.AddInput("yes");
            UnitTesting.AddInput("yes");
            UnitTesting.AddInput("\n");
            deposit.GetAwaiter().GetResult();
            int res = UnitTesting.WatchCount(re);

            UnitTesting.EndTest();
            Log.Information($"Recorded {res} occurrences.");
            Assert.IsTrue(res > 0);
        }
Пример #11
0
 public void TestGetDollarAmountFraction()
 {
     UnitTesting.SetupTesting();
     Assert.IsTrue(TestGetDollarAmount("45.55", 45.55M));
     UnitTesting.EndTest();
 }
Пример #12
0
 public void TestGetDollarAmountBasic()
 {
     UnitTesting.SetupTesting();
     Assert.IsTrue(TestGetDollarAmount("45", 45));
     UnitTesting.EndTest();
 }