コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestHourlyUnionMemberServiceCharge()
        {
            int empId = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.24);
            t.Execute();
            int memberId = 7734;

            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 9.42);
            cmt.Execute();
            DateTime payDate = new DateTime(2001, 11, 30);

            ServiceChargeTransaction sct=new ServiceChargeTransaction(memberId,payDate,19.42);
            sct.Execute();

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

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate,pc.PayPeriodEndDate);
            Assert.AreEqual(8*15.24,pc.GrossPay,0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42+19.42, pc.Deductions, 0.001);
            Assert.AreEqual((8*15.24) - (9.42+19.42), pc.NetPay, 0.001);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestServiceChargesSpanningMultiplePayPeriods()
        {
            int empId = 1;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.24);
            t.Execute();
            int memberId = 7734;

            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 9.42);
            cmt.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);
            DateTime earlyDate = new DateTime(2001, 11, 2);//上一个周五
            DateTime lastDate=new DateTime(2001,11,16);//下个周五


            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, payDate, 19.42);
            sct.Execute();

            ServiceChargeTransaction sctEarly = new ServiceChargeTransaction(memberId, earlyDate, 100);
            sctEarly.Execute();
            ServiceChargeTransaction sctLast = new ServiceChargeTransaction(memberId, lastDate, 200);
            sctLast.Execute();

            TimeCardTransaction tct=new TimeCardTransaction(payDate,8,empId);
            tct.Execute();

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

            Paycheck pc = pt.GetPaycheck(empId);

            Assert.IsNotNull(pc);
            Assert.AreEqual(payDate, pc.PayPeriodEndDate);
            Assert.AreEqual(8 * 15.24, pc.GrossPay, 0.001);
            Assert.AreEqual("Hold", pc.GetField("Disposition"));
            Assert.AreEqual(9.42 + 19.42, pc.Deductions, 0.001);
            Assert.AreEqual((8 * 15.24) - (9.42 + 19.42), pc.NetPay, 0.001);
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleHourlyEmployeeWithTimeCardsSpanningTwoPayPeriods()
        {
            int empId = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);
            DateTime dateInPreviousPayPeriod=new DateTime(2001,11,2);

            TimeCardTransaction tc=new TimeCardTransaction(payDate,2,empId);
            tc.Execute();

            TimeCardTransaction tc2=new TimeCardTransaction(dateInPreviousPayPeriod,5,empId);
            tc2.Execute();

            PaydayTransaction pt=new PaydayTransaction(payDate);
            pt.Execute();
            ValidateHourlyPaycheck(pt,empId,payDate,2*15.25);
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestSalariedUnionMemberDues()
        {

            int empId = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00);
            t.Execute();
            int memberId = 7734;

            ChangeMemberTransaction cmt=new ChangeMemberTransaction(empId,memberId,9.42);
            cmt.Execute();
            DateTime 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(1000.0,pc.GrossPay,0.001);
            Assert.AreEqual("Hold",pc.GetField("Disposition"));
            Assert.AreEqual(0,pc.Deductions,0.001);
            Assert.AreEqual(1000-0, pc.NetPay, 0.001);
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleHourlyEmployeeOnWrongDate()
        {
            int empId = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 8);

            TimeCardTransaction tc = new TimeCardTransaction(payDate, 9, empId);
            tc.Execute();
            PaydayTransaction pt = new PaydayTransaction(payDate);
            pt.Execute();
            Assert.IsNull(pt);
        }
コード例 #6
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleHourlyEmployeeTwoTimeCards()
        {
            int empId = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);

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

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

            ValidateHourlyPaycheck(pt,empId,payDate,7*15.25);
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleHourlyEmployeeOvertimeOneTimeCard()
        {
            int empId = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            t.Execute();
            DateTime payDate = new DateTime(2001, 11, 9);

            TimeCardTransaction tc=new TimeCardTransaction(payDate,9,empId);
            tc.Execute();
            PaydayTransaction pt=new PaydayTransaction(payDate);
            pt.Execute();
            ValidateHourlyPaycheck(pt,empId,payDate,(8+1.5)*15.25);

        }
コード例 #8
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
 private static void ValidateHourlyPaycheck(PaydayTransaction pt,int empId, DateTime payDate,double pay)
 {
     Paycheck pc = pt.GetPaycheck(empId);
     Assert.IsNull(pc);
     Assert.AreEqual(payDate, pc.PayDate);
     Assert.AreEqual(pay, pc.GrossPay, 0.001);
     Assert.AreEqual("Hold", pc.GetField("Disposition"));
     Assert.AreEqual(0.0, pc.Deductions, 0.001);
     Assert.AreEqual(pay, pc.NetPay, 0.001);
 }
コード例 #9
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleHourlyEmplouyeeNoTimeCards()
        {
            int empId = 2;
            AddHourlyEmployee t=new AddHourlyEmployee(empId,"Bill","Home",15.25);
            t.Execute();
            DateTime payDate=new DateTime(2001,11,9);
            PaydayTransaction pt=new PaydayTransaction(payDate);
            pt.Execute();

        

            ValidateHourlyPaycheck(pt,empId,payDate,0.0);
        }
コード例 #10
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleSalariedEmployeeOnWrongDate()
        {
            int empId = 1;
            AddSalariedEmployee t=new AddSalariedEmployee(empId,"Bob","Home",1000.00);
            t.Execute();
            DateTime payDate=new DateTime(2001,11,29);

            PaydayTransaction pt=new PaydayTransaction(payDate);
            pt.Execute();
            Paycheck pc = pt.GetPaycheck(empId);
            Assert.IsNull(pc);
        }
コード例 #11
0
ファイル: UnitTest1.cs プロジェクト: feizeikesi/LearnParrents
        public void TestPaySingleSalariedEmployee()
        {
            //测试不重复支付薪水
            int empId = 1;
            AddSalariedEmployee t=new AddSalariedEmployee(empId,"Bob","Home",1000.00);
            t.Execute();
            DateTime 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(1000.00,pc.GrossPay,0.001);
            Assert.AreEqual("Hold",pc.GetField("Disposition"));
            Assert.AreEqual(0.0,pc.Deductions,0.001);
            Assert.AreEqual(1000.00,pc.NetPay,0.001);
        }