public void TestTimeCardTransaction()
        {
            int empId           = 5;
            var name            = "Łukasz";
            var hourlyRate      = 15.25;
            var date            = new DateTime(2005, 7, 31);
            var hours           = 8.0;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();

            TimeCardTransaction tct = new TimeCardTransaction(date, hours, empId);

            tct.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            IPaymentClassification pc = e.Classification;

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

            TimeCard tc = hc.GetTimeCard(date);

            Assert.IsNotNull(tc);
            Assert.AreEqual(hours, tc.Hours);
        }
Ejemplo n.º 2
0
        public void TestAddCommissionedEmployee()
        {
            int    empId              = 2;
            string name               = "Tadeusz";
            double salary             = 1000.0;
            double commissionedRate   = 5.0;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, name, "Home", salary, commissionedRate);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is CommissionedClassification);

            CommissionedClassification cc = pc as CommissionedClassification;

            Assert.AreEqual(salary, cc.Salary, .001);
            Assert.AreEqual(commissionedRate, cc.CommissionRate, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is BiweeklySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Ejemplo n.º 3
0
        public void TestAddHourlyEmployee()
        {
            int               empId      = 3;
            string            name       = "Tomasz";
            double            hourlyRate = 20.0;
            AddHourlyEmployee t          = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is HourlyClassification);

            HourlyClassification hc = pc as HourlyClassification;

            Assert.AreEqual(hourlyRate, hc.HourlyRate, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is WeeklySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Ejemplo n.º 4
0
        public void TestAddSalariedEmployee()
        {
            int    empId          = 1;
            string name           = "Bogdan";
            double salary         = 1000.0;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, name, "Home", salary);

            t.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.AreEqual(name, e.Name);

            IPaymentClassification pc = e.Classification;

            Assert.IsTrue(pc is SalariedClassification);

            SalariedClassification sc = pc as SalariedClassification;

            Assert.AreEqual(salary, sc.Salary, .001);
            IPaymentSchedule ps = e.Schedule;

            Assert.IsTrue(ps is MonthlySchedule);

            IPaymentMethod pm = e.Method;

            Assert.IsTrue(pm is HoldMethod);
        }
Ejemplo n.º 5
0
        public void Execute()
        {
            IPaymentClassification pc = MakeClassification();
            IPaymentSchedule       ps = MakeSchedule();
            IPaymentMethod         pm = new HoldMethod();
            IAffiliation           af = new NoAffiliation();

            Employee e = new Employee(_empId, _name, _address);

            e.Classification = pc;
            e.Schedule       = ps;
            e.Method         = pm;
            e.Affiliation    = af;
            PayrollDatabase.AddEmlpoyee(e.EmpId, e);
        }