Esempio n. 1
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));
        }
Esempio n. 2
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));
        }
        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));
        }
Esempio n. 5
0
        public void CalculateWeeklyPayTest()
        {
            double expected = 2000;
            double actual   = hourlyWorker.CalculateWeeklyPay(40);

            Assert.AreEqual(expected, actual, "Hourly rate of 50 and worked 40 hours");


            expected = 2750;
            actual   = hourlyWorker.CalculateWeeklyPay(50);
            Assert.AreEqual(expected, actual, "Hourly rate of 50 and worked 50 hours");
        }
Esempio n. 6
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
        }
        public void HourlyOvertimeTest()
        {
            HourlyWorker thisWorker = new HourlyWorker(20, "John", "Doe", 45);
            double       totalPay   = thisWorker.CalculateWeeklyPay(thisWorker.HoursWorked);

            Assert.AreEqual(950, totalPay);
        }
Esempio n. 8
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));
        }
Esempio n. 9
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");
        }
Esempio n. 10
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));
        }
Esempio n. 11
0
        public void CalculateWeekly_0Hours_0Pay()
        {
            HourlyWorker hw = new HourlyWorker(1.0, "John", "Doe");

            Assert.AreEqual(0, hw.CalculateWeeklyPay(0));
        }
Esempio n. 12
0
 public void HourlyWorkerCalculateWeeklyPay()
 {
     Assert.AreEqual(900, _hourlyWorker.CalculateWeeklyPay(9), "passed weeklyHours 9");
     Assert.AreEqual(-900, _hourlyWorker.CalculateWeeklyPay(-9), "passed weeklyHours -9");
     Assert.AreEqual(500, _hourlyWorker.CalculateWeeklyPay(5), "passed weeklyHours 5");
 }