public void HourlyOvertimeTest()
        {
            HourlyWorker thisWorker = new HourlyWorker(20, "John", "Doe", 45);
            double       totalPay   = thisWorker.CalculateWeeklyPay(thisWorker.HoursWorked);

            Assert.AreEqual(950, totalPay);
        }
Exemplo n.º 2
0
        public void CalculateWeeklyPay_OverTime()
        {
            HourlyWorker hw = new HourlyWorker(1.0, "John", "Doe");

            Assert.AreEqual(41.5, hw.CalculateWeeklyPay(41));
            Assert.AreEqual(70, hw.CalculateWeeklyPay(60));
        }
Exemplo n.º 3
0
        public void CalculateWeekly_RegularTime()
        {
            HourlyWorker hw = new HourlyWorker(1.0, "John", "Doe");

            Assert.AreEqual(1, hw.CalculateWeeklyPay(1));
            Assert.AreEqual(20, hw.CalculateWeeklyPay(20));
            Assert.AreEqual(40, hw.CalculateWeeklyPay(40));
        }
Exemplo n.º 4
0
        private int VerifyCallStack()
        {
            Worker       e1 = new Worker(30000);
            Worker       e2 = new Worker(500, 52);
            HourlyWorker e3 = new HourlyWorker(10000);

            return(0); //set bp #3
        }
        public void CalculateWeeklyPay()
        {
            HourlyWorker test = new HourlyWorker(20, "test", "test");

            Assert.AreEqual(0, test.CalculateWeeklyPay(0), "input : 0");
            Assert.AreEqual(1100, test.CalculateWeeklyPay(50), "input : 50");
            Assert.AreEqual(0, test.CalculateWeeklyPay(-30), "input : -30");
            Assert.AreEqual(89600, test.CalculateWeeklyPay(3000), "input : 3000");
        }
        public void HourlyWorkerAllTests()
        {
            HourlyWorker hourlyTest = new HourlyWorker(5.50, "Jacob", "Rutter");

            Assert.AreEqual(5.50, hourlyTest.HourlyRate);
            Assert.AreEqual("Jacob", hourlyTest.FirstName);
            Assert.AreEqual("Rutter", hourlyTest.LastName);
            Assert.AreEqual(55, hourlyTest.CalculateWeeklyPay(10));
            Assert.AreEqual(302.5, hourlyTest.CalculateWeeklyPay(50));
        }
Exemplo n.º 7
0
        public void CalculateWeeklyPay_Tests()
        {
            int          hoursWorked = 10;
            double       HoursWorked_Result;
            HourlyWorker hourlyWorker = new HourlyWorker(2.0, "Warren", "stowe");

            HoursWorked_Result = hourlyWorker.CalculateWeeklyPay(hoursWorked);
            //assert is not null
            Assert.IsNotNull(HoursWorked_Result, "should not be null");
            Assert.AreEqual(HoursWorked_Result, 20.0, "result is  hours worked times hourly rate");
            Assert.IsTrue(HoursWorked_Result >= 0, "not a positive number");
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Boss            boss            = new Boss("John", "Smith", 800);
            CommisionWorker commisionWorker = new CommisionWorker("Sue", "Jones", 400, 3, 150);
            PieceWorker     pieceWorker     = new PieceWorker("Bob", "Lewis", (decimal)2.5, 200);
            HourlyWorker    hourlyWorker    = new HourlyWorker("Karen", "Priece", (decimal)13.75, 50);

            Employee[] workers = { boss, commisionWorker, pieceWorker, hourlyWorker };

            foreach (Employee worker in workers)
            {
                Console.WriteLine($"{worker}.\nEarned: {worker.Earnings().ToString("C")}");
            }
        }
Exemplo n.º 9
0
        public void HourlyWorkerGetsTimeAndAHalfForOvertime()
        {
            // Arrange
            Worker worker = new HourlyWorker(10.00M);

            // Act
            int     hoursWorked = 50;
            decimal pay         = worker.CalculateWeeklyPay(hoursWorked);

            // Assert
            Assert.AreEqual(550.00M, pay);

            // Check another example
            Assert.AreEqual(1300.00m, worker.CalculateWeeklyPay(100)); // 40 * 10 + 60 * 15 = 400 + 900 = 1300
        }
Exemplo n.º 10
0
        public void HourlyWorkerGetsPaidHoursTimesRate()
        {
            // Arrange
            Worker worker = new HourlyWorker(10.00M);

            // Act
            int     hoursWorked = 40;
            decimal pay         = worker.CalculateWeeklyPay(hoursWorked);

            // Assert
            Assert.AreEqual(400.00M, pay);

            // Add another assert that stretches our code

            Assert.AreEqual(200.00m, worker.CalculateWeeklyPay(20));

            // Let's write a couple more tests to make sure...
            Assert.AreEqual(0.00m, worker.CalculateWeeklyPay(0));
        }
Exemplo n.º 11
0
        private void AddRandomWorker_Click(object sender, EventArgs e)
        {
            Random random  = new Random();
            string name    = "Firstname" + random.Next(1, 100);
            string surname = "Surname" + random.Next(1, 100);
            Worker worker;

            if (random.Next(0, 2) == 1)
            {
                worker = new HourlyWorker(name, surname,
                                          random.Next(30, 1000), random.Next(80, 200));
            }
            else
            {
                worker = new MonthlyWorker(name, surname,
                                           random.Next(10000, 100000),
                                           random.Next(10, 200) * 0.01,
                                           random.Next(0, 5000));
            }
            WorkerList.Add(worker);
            WorkersGridView.Rows.Add(worker.Firstname, worker.Surname,
                                     worker.GetSalaryValue());
        }
Exemplo n.º 12
0
        public void HourlyWorkerTest()
        {
            HourlyWorker myHourlyWorker = new HourlyWorker(25.25, "Johnny", "Doe");

            Assert.AreEqual("Johnny", myHourlyWorker.FirstName);
            Assert.AreEqual("Doe", myHourlyWorker.LastName);
            Assert.AreEqual(25.25, myHourlyWorker.HourlyRate);
            Assert.AreEqual(1010, myHourlyWorker.CalculateWeeklyPay(40));
            Assert.AreEqual(40, myHourlyWorker.HoursWorked);

            myHourlyWorker = new HourlyWorker(-25.00, "", "");
            Assert.AreEqual("unknown", myHourlyWorker.FirstName);
            Assert.AreEqual("unknown", myHourlyWorker.LastName);
            Assert.AreEqual(0, myHourlyWorker.HourlyRate);
            Assert.AreEqual(0, myHourlyWorker.CalculateWeeklyPay(-40));
            Assert.AreEqual(0, myHourlyWorker.HoursWorked);

            myHourlyWorker = new HourlyWorker(0, null, null);
            Assert.AreEqual("unknown", myHourlyWorker.FirstName);
            Assert.AreEqual("unknown", myHourlyWorker.LastName);
            Assert.AreEqual(0, myHourlyWorker.HourlyRate);

            myHourlyWorker = new HourlyWorker(25, "Johnny", "Doe");
            Assert.AreEqual(25, myHourlyWorker.HourlyRate);

            myHourlyWorker = new HourlyWorker(25.009993, "Johnny", "Doe");
            Assert.AreEqual(25.01, myHourlyWorker.HourlyRate);

            myHourlyWorker = new HourlyWorker(25.004443, "Johnny", "Doe");
            Assert.AreEqual(25, myHourlyWorker.HourlyRate);

            Assert.AreEqual(0, myHourlyWorker.CalculateWeeklyPay(-40));

            Assert.AreEqual(0, myHourlyWorker.CalculateWeeklyPay(0));

            Assert.AreEqual(1750, myHourlyWorker.CalculateWeeklyPay(60));
        }
Exemplo n.º 13
0
        public void CalculateWeekly_0Hours_0Pay()
        {
            HourlyWorker hw = new HourlyWorker(1.0, "John", "Doe");

            Assert.AreEqual(0, hw.CalculateWeeklyPay(0));
        }