Пример #1
0
        public void PaySingleHourlyEmployeeTwoTimeCards()
        {
            int               empId      = 3;
            string            name       = "Marek";
            string            address    = "Home";
            double            hourlyRate = 15.25;
            int               hours1     = 2;
            int               hours2     = 5;
            AddHourlyEmployee t          = new AddHourlyEmployee(empId, name, address, hourlyRate);

            t.Execute();
            DateTime            payDate = new DateTime(2001, 11, 9); // piątek
            TimeCardTransaction tc1     = new TimeCardTransaction(payDate, hours1, empId);

            tc1.Execute();
            TimeCardTransaction tc2 = new TimeCardTransaction(payDate.AddDays(-1), hours2, empId);

            tc2.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            var pc = pt.GetPayCheck(empId);

            ValidatePayCheck(pt, empId, payDate, (7) * hourlyRate);
        }
Пример #2
0
        public void SalariedUnionMemberDuesTest()
        {
            var empId             = 1;
            var name              = "Bogdan";
            var address           = "Home";
            var salary            = 1000.0;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, name, address, salary);

            t.Execute();
            var memberId = 7734;
            var dues     = 9.42;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, dues);

            cmt.Execute();
            var payDate          = new DateTime(2001, 11, 30);
            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            PayCheck pc = pt.GetPayCheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayDate);
            Assert.AreEqual(salary, pc.GrossPay, .001);
            Assert.AreEqual(5 * dues, pc.Deductions, .001);
            Assert.AreEqual(salary - (5 * dues), pc.NetPay, .001);
        }
Пример #3
0
        private void ValidatePayCheck(PaydayTransaction pt, int empId, DateTime date, double pay)
        {
            PayCheck pc = pt.GetPayCheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(date, pc.PayDate);
            Assert.AreEqual(pay, pc.GrossPay, .001);
            Assert.AreEqual(0.0, pc.Deductions, .001);
            Assert.AreEqual(pay, pc.NetPay, .001);
        }
Пример #4
0
        public void PayingSingleHourlyEmployeeWithouTTimeCards()
        {
            int               employeeId = AddHourlyEmployee();
            DateTime          payDate    = new DateTime(2019, 4, 26);
            PaydayTransaction pt         = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            ValidateHourlyPayCheck(payDate, pc, 0.0);
        }
Пример #5
0
        public void PayingSingleCommissionedEmployeeWithoutSaleReciept()
        {
            int      employeeId = AddCommissionedEmployee();
            DateTime payDate    = new DateTime(2019, 4, 19);

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            ValidateHourlyPayCheck(payDate, pc, 800.0);
        }
Пример #6
0
        public void PayingSingleHourlyEmployeeWithTwoTimeCards()
        {
            int employeeId = AddHourlyEmployee();

            AddTimeCard(employeeId, new DateTime(2019, 4, 22), 2);
            AddTimeCard(employeeId, new DateTime(2019, 4, 23), 5);

            DateTime          payDate = new DateTime(2019, 4, 26);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            ValidateHourlyPayCheck(payDate, pc, 7 * 19.25);
        }
Пример #7
0
        public void PaySingleSalariedEmployeeOnWrongDate()
        {
            int employeeId           = 21;
            AddEmployTransaction aet = new AddSalariedEmployee(
                employeeId, "Bob", "Home", 1000.0
                );

            aet.Execute();
            DateTime          payDate = new DateTime(2019, 4, 28);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            pc.Should().BeNull();
        }
Пример #8
0
        public void PayingSingleHourlyEmployeeSpanningTwoPayPeriod()
        {
            int      employeeId     = AddHourlyEmployee();
            DateTime payDate        = new DateTime(2019, 4, 26);
            DateTime previosPayDate = payDate.AddDays(-7);

            AddTimeCard(employeeId, previosPayDate, 2);
            AddTimeCard(employeeId, payDate, 5);

            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            ValidateHourlyPayCheck(payDate, pc, 5 * 19.25);
        }
Пример #9
0
        public void PayingSingleHourlyEmployeeOnWrongDate()
        {
            int employeeId          = AddHourlyEmployee();
            TimeCardTransaction tct = new TimeCardTransaction(
                employeeId, new DateTime(2019, 4, 22), 9);

            tct.Execute();

            DateTime          payDate = new DateTime(2019, 4, 25);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            pc.Should().BeNull();
        }
Пример #10
0
        public void PayingSingleHourlyEmployeeWithOneOverTimeCard()
        {
            int employeeId          = AddHourlyEmployee();
            TimeCardTransaction tct = new TimeCardTransaction(
                employeeId, new DateTime(2019, 4, 22), 9);

            tct.Execute();

            DateTime          payDate = new DateTime(2019, 4, 26);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            ValidateHourlyPayCheck(payDate, pc, (8 + 1.5) * 19.25);
        }
Пример #11
0
        public void PaySingleHourlyEmployeeWrongDate()
        {
            int               empId      = 1;
            string            name       = "Bogdan";
            string            address    = "Home";
            double            hourlyRate = 15.25;
            int               hours      = 8;
            AddHourlyEmployee t          = new AddHourlyEmployee(empId, name, address, hourlyRate);

            t.Execute();
            DateTime            payDate = new DateTime(2001, 11, 8);
            TimeCardTransaction tc      = new TimeCardTransaction(payDate, hours, empId);

            tc.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            var pc = pt.GetPayCheck(empId);

            Assert.IsNull(pc);
        }
Пример #12
0
        public void PayCommissionEmployeeWithoutSalee()
        {
            int    empId              = 1;
            string name               = "Andrzej";
            string address            = "Home";
            double salary             = 1000;
            double commissionRate     = 0.1;
            int    sale1              = 1500;
            int    sale2              = 2500;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, name, address, salary, commissionRate);

            t.Execute();
            DateTime payDate         = new DateTime(2001, 11, 9); // 2 piątek
            CommissionTransaction ct = new CommissionTransaction(payDate, sale1, empId);

            ct.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate);

            pt.Execute();
            PayCheck pc = pt.GetPayCheck(empId);
        }
Пример #13
0
        public void PaySingleSalariedEmployee()
        {
            int employeeId           = 20;
            AddEmployTransaction aet = new AddSalariedEmployee(
                employeeId, "Bob", "Home", 1000.0
                );

            aet.Execute();
            DateTime          payDate = new DateTime(2019, 4, 30);
            PaydayTransaction pt      = new PaydayTransaction(payDate);

            pt.Execute();

            PayCheck pc = pt.GetPayCheck(employeeId);

            pc.Should().NotBeNull();
            pc.PayDate.Should().Be(payDate);
            pc.GrossPay.Should().Be(1000.0);
            pc.GetField("Disposition").Should().Be("Hold");
            pc.Deductions.Should().Be(0.0);
            pc.NetPay.Should().Be(1000.0);
        }