Пример #1
0
        public void HourlyUnionMemberServiceCharge()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.24, database);

            t.Execute();
            int memberId = 7734;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 9.42, database);

            cmt.Execute();
            DateTime payDate             = new DateTime(2001, 11, 9);
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(memberId, payDate, 19.42, database);

            sct.Execute();
            TimeCardTransaction tct =
                new TimeCardTransaction(payDate, 8.0, empId, database);

            tct.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, .001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, .001);
        }
Пример #2
0
        public void TestAddHourlyEmployee()
        {
            int empId           = 2;
            AddHourlyEmployee t =
                new AddHourlyEmployee(empId, "Micah", "Home", 200.00, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.AreEqual("Micah", e.Name);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.AreEqual(200.00, hc.HourlyRate, .001);
            PaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);

            PaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Пример #3
0
        public void ChangeUnionMember()
        {
            int empId           = 9;
            AddHourlyEmployee t =
                new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database);

            t.Execute();
            int memberId = 7743;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 99.42, database);

            cmt.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is UnionAffiliation);
            UnionAffiliation uf = affiliation as UnionAffiliation;

            Assert.AreEqual(99.42, uf.Dues, .001);
            Employee member = database.GetUnionMember(memberId);

            Assert.IsNotNull(member);
            Assert.AreEqual(e, member);
        }
Пример #4
0
        public void ChangeUnaffiliatedMember()
        {
            int empId           = 10;
            AddHourlyEmployee t =
                new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database);

            t.Execute();
            int memberId = 7743;

            new ChangeMemberTransaction(empId, memberId, 99.42, database).Execute();
            ChangeUnaffiliatedTransaction cut =
                new ChangeUnaffiliatedTransaction(empId, database);

            cut.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is NoAffiliation);
            Employee member = database.GetUnionMember(memberId);

            Assert.IsNull(member);
        }
Пример #5
0
        public void AddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            UnionAffiliation af = new UnionAffiliation();

            e.Affiliation = af;
            int memberId = 86;             // Maxwell Smart

            database.AddUnionMember(memberId, e);
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(
                    memberId, new DateTime(2005, 8, 8), 12.95, database);

            sct.Execute();
            ServiceCharge sc =
                af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, .001);
        }
Пример #6
0
        public void TestTimeCardTransaction()
        {
            int empId           = 5;
            AddHourlyEmployee t =
                new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database);

            t.Execute();
            TimeCardTransaction tct =
                new TimeCardTransaction(
                    new DateTime(2005, 7, 31), 8.0, empId, database);

            tct.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            PaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            TimeCard tc = hc.GetTimeCard(new DateTime(2005, 7, 31));

            Assert.IsNotNull(tc);
            Assert.AreEqual(8.0, tc.Hours);
        }
Пример #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            int               id      = int.Parse(textid.Text);
            string            name    = textname.Text;
            string            address = textaddress.Text;
            float             rate    = float.Parse(textrate.Text);
            PayrollDatabase   pd      = new sytpayrolldatabase();
            AddHourlyEmployee emp     = new AddHourlyEmployee(id, name, address, rate, pd);

            emp.Execute();
        }
Пример #8
0
        public void PayingSingleHourlyEmployeeNoTimeCards()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime          payDate = new DateTime(2001, 11, 9);    // Friday
            PaydayTransaction pt      = new PaydayTransaction(payDate, database);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 0.0);
        }
Пример #9
0
        public void TestChangeNameTransaction()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database);

            t.Execute();
            ChangeNameTransaction cnt = new ChangeNameTransaction(empId, "Bob", database);

            cnt.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            Assert.AreEqual("Bob", e.Name);
        }
Пример #10
0
        public void ServiceChargesSpanningMultiplePayPeriods()
        {
            int empId           = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.24, database);

            t.Execute();
            int memberId = 7734;
            ChangeMemberTransaction cmt =
                new ChangeMemberTransaction(empId, memberId, 9.42, database);

            cmt.Execute();
            DateTime payDate   = new DateTime(2001, 11, 9);
            DateTime earlyDate =
                new DateTime(2001, 11, 2);                 // previous Friday
            DateTime lateDate =
                new DateTime(2001, 11, 16);                // next Friday
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(memberId, payDate, 19.42, database);

            sct.Execute();
            ServiceChargeTransaction sctEarly =
                new ServiceChargeTransaction(memberId, earlyDate, 100.00, database);

            sctEarly.Execute();
            ServiceChargeTransaction sctLate =
                new ServiceChargeTransaction(memberId, lateDate, 200.00, database);

            sctLate.Execute();
            TimeCardTransaction tct =
                new TimeCardTransaction(payDate, 8.0, empId, database);

            tct.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, .001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, .001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, .001);
        }
Пример #11
0
        public void PaySingleHourlyEmployeeOvertimeOneTimeCard()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);             // Friday

            TimeCardTransaction tc =
                new TimeCardTransaction(payDate, 9.0, empId, database);

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

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, (8 + 1.5) * 15.25);
        }
Пример #12
0
        public void PaySingleHourlyEmployeeOneTimeCard()
        {
            var empId = 2;
            var t     = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            var payDate = new DateTime(2001, 11, 9); // Friday

            var tc =
                new TimeCardTransaction(payDate, 2.0, empId, database);

            tc.Execute();
            var pt = new PaydayTransaction(payDate, database);

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 30.5);
        }
Пример #13
0
        public void PaySingleHourlyEmployeeOnWrongDate()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 8);             // Thursday

            TimeCardTransaction tc =
                new TimeCardTransaction(payDate, 9.0, empId, database);

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

            pt.Execute();

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNull(pc);
        }
Пример #14
0
        public void PaySingleHourlyEmployeeTwoTimeCards()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);             // Friday

            TimeCardTransaction tc =
                new TimeCardTransaction(payDate, 2.0, empId, database);

            tc.Execute();
            TimeCardTransaction tc2 =
                new TimeCardTransaction(payDate.AddDays(-1), 5.0, empId, database);

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

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 7 * 15.25);
        }
Пример #15
0
        TestPaySingleHourlyEmployeeWithTimeCardsSpanningTwoPayPeriods()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);             // Friday
            DateTime dateInPreviousPayPeriod =
                new DateTime(2001, 10, 30);

            TimeCardTransaction tc =
                new TimeCardTransaction(payDate, 2.0, empId, database);

            tc.Execute();
            TimeCardTransaction tc2 = new TimeCardTransaction(
                dateInPreviousPayPeriod, 5.0, empId, database);

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

            pt.Execute();
            ValidatePaycheck(pt, empId, payDate, 2 * 15.25);
        }