Beispiel #1
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();
        }
        public void TestMonthsBefore()
        {
            UnitTesting.SetupTesting();
            int res = new DateTime(2019, 08, 30).MonthsBefore(new DateTime(2019, 09, 30));

            Log.Debug($"MonthsFrom result 1: {res}");
            Assert.AreEqual(1, res);
            res = new DateTime(2019, 08, 30).MonthsBefore(new DateTime(2019, 09, 29));
            Log.Debug($"MonthsFrom result 2: {res}");
            Assert.AreEqual(0, res);
            res = new DateTime(2019, 09, 30).MonthsBefore(new DateTime(2019, 09, 29));
            Log.Debug($"MonthsFrom result 3: {res}");
            Assert.AreEqual(0, res);
            res = new DateTime(2019, 10, 29).MonthsBefore(new DateTime(2019, 09, 29));
            Log.Debug($"MonthsFrom result 4: {res}");
            Assert.AreEqual(-1, res);
            res = new DateTime(2014, 1, 1).MonthsBefore(new DateTime(2014, 2, 1));
            Log.Debug($"MonthsFrom result 5: {res}");
            Assert.AreEqual(1, res);
            res = new DateTime(2014, 1, 1).MonthsBefore(new DateTime(2014, 1, 31));
            Log.Debug($"MonthsFrom result 6: {res}");
            Assert.AreEqual(0, res);
            res = new DateTime(2014, 1, 1).MonthsBefore(new DateTime(2014, 2, 2));
            Log.Debug($"MonthsFrom result 7: {res}");
            Assert.AreEqual(1, res);

            // 31 Jan to 28 Feb
            Assert.AreEqual(1, new DateTime(2014, 1, 31).MonthsBefore(new DateTime(2014, 2, 28)));
            // Leap year 29 Feb to 29 Mar
            Assert.AreEqual(1, new DateTime(2012, 2, 29).MonthsBefore(new DateTime(2012, 3, 29)));
            // Whole year minus a day
            Assert.AreEqual(11, new DateTime(2012, 1, 1).MonthsBefore(new DateTime(2012, 12, 31)));
            // Whole year
            Assert.AreEqual(12, new DateTime(2012, 1, 1).MonthsBefore(new DateTime(2013, 1, 1)));
            // 29 Feb (leap) to 28 Feb (non-leap)
            Assert.AreEqual(12, new DateTime(2012, 2, 29).MonthsBefore(new DateTime(2013, 2, 28)));
            // 100 years
            Assert.AreEqual(1200, new DateTime(2000, 1, 1).MonthsBefore(new DateTime(2100, 1, 1)));
            // Same date
            Assert.AreEqual(0, new DateTime(2014, 8, 5).MonthsBefore(new DateTime(2014, 8, 5)));
            // Past date
            Assert.AreEqual(-6, new DateTime(2012, 1, 1).MonthsBefore(new DateTime(2011, 6, 10)));
        }
Beispiel #3
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);
        }
Beispiel #4
0
 //[TestMethod]
 public void TestCreateCustomer()
 {
     UnitTesting.SetupTesting();
     Assert.IsTrue(true);
 }
 public void TestGetDollarAmountFraction()
 {
     UnitTesting.SetupTesting();
     Assert.IsTrue(TestGetDollarAmount("45.55", 45.55M));
     UnitTesting.EndTest();
 }
 public void TestGetDollarAmountBasic()
 {
     UnitTesting.SetupTesting();
     Assert.IsTrue(TestGetDollarAmount("45", 45));
     UnitTesting.EndTest();
 }
 public static bool TestGetDollarAmount(string input, decimal exp)
 {
     Log.Information($"TestGetDollarAmount\ninput:{input}|exp:{exp}");
     UnitTesting.AddInput(input);
     return(exp == ConsoleUtil.GetDollarAmount());
 }