Exemple #1
0
        public async Task ExecuteAsync()
        {
            Classification.PaymentClassification pc = MakeClassification();
            IPaymentSchedule ps = MakeSchedule();
            IPaymentMethod   pm = new HoldMethod();
            Employee         e  = new Employee(EmpId, Name, Address);

            e.Classification = pc;
            e.Schedule       = ps;
            e.Method         = pm;

            await PayrollDatabase.AddEmployeeAsync(EmpId, e);
        }
Exemple #2
0
        public async Task ChangeSalariedTransaction()
        {
            int empId = 7;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2);
            await t.ExecuteAsync();

            ChangeSalariedTransaction cht = new ChangeSalariedTransaction(empId, 2500);
            await cht.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);
            Classification.PaymentClassification pc = e.Classification;
            Assert.NotNull(pc);
            Assert.True(pc is Payroll.Classification.SalariedClassification);
            Payroll.Classification.SalariedClassification sc = pc as Payroll.Classification.SalariedClassification;
            Assert.Equal(2500, sc.Salary);
            IPaymentSchedule ps = e.Schedule;

            Assert.True(ps is BiWeeklySchedule);
        }
Exemple #3
0
        public async Task TimeCardTransaction()
        {
            int empId           = 3;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            await t.ExecuteAsync();

            TimeCardTransaction tct = new TimeCardTransaction(new DateTime(2005, 7, 31), 8.0, empId);
            await tct.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);

            Classification.PaymentClassification pc = e.Classification;
            Assert.True(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

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

            Assert.NotNull(tc);
            Assert.Equal(8.0, tc.Hours);
        }
Exemple #4
0
        public async Task AddSalariedEmployee()
        {
            int empId             = 1;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.0);
            await t.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.Equal("Bob", e.Name);

            Classification.PaymentClassification pc = e.Classification;
            Assert.True(pc is Payroll.Classification.SalariedClassification);
            Payroll.Classification.SalariedClassification sc = pc as Payroll.Classification.SalariedClassification;
            Assert.Equal(1000.00, sc.Salary);
            IPaymentSchedule ps = e.Schedule;

            Assert.True(ps is MonthlySchedule);

            IPaymentMethod pm = e.Method;

            Assert.True(pm is HoldMethod);
        }
Exemple #5
0
        public async Task ChangeHourlyTransaction()
        {
            int empId = 6;
            AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 3.2);
            await t.ExecuteAsync();

            ChangeHourlyTransaction cht = new ChangeHourlyTransaction(empId, 27.52);
            await cht.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);
            Classification.PaymentClassification pc = e.Classification;
            Assert.NotNull(pc);
            Assert.True(pc is HourlyClassification);
            HourlyClassification hc = pc as HourlyClassification;

            Assert.Equal(27.52, hc.HourlyRate);
            IPaymentSchedule ps = e.Schedule;

            Assert.True(ps is WeeklySchedule);
        }
Exemple #6
0
        public async Task ChangeCommissionedTransaction()
        {
            int empId             = 8;
            AddSalariedEmployee t = new AddSalariedEmployee(empId, "Lance", "Home", 2500);
            await t.ExecuteAsync();

            ChangeCommissionedTransaction cht = new ChangeCommissionedTransaction(empId, 2600, 4.4);
            await cht.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);
            Classification.PaymentClassification pc = e.Classification;
            Assert.NotNull(pc);
            Assert.True(pc is CommissionedClassification);
            CommissionedClassification sc = pc as CommissionedClassification;

            Assert.Equal(2600, sc.BaseRate);
            Assert.Equal(4.4, sc.CommissionedRate);
            IPaymentSchedule ps = e.Schedule;

            Assert.True(ps is MonthlySchedule);
        }