public void TestAddSalariedEmployee() { int empId = 1; app.ExexcuteTransaction("addSalariedEmployee", RequestFactory.rf.MakeSalariedEmployeeRequest(empId, "Bob", "Home", 1000)); Employee e = PayrollDb.GetEmployee(empId); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(1000.00, sc.Salary, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void AddServiceCharge() { int empId = 2; app.ExexcuteTransaction("addHourlyEmployee", RequestFactory.rf.MakeHourlyEmployeeRequest(empId, "Bob", "Home", 50)); Employee e = PayrollDb.GetEmployee(empId); Assert.IsNotNull(e); UnionAffiliation af = new UnionAffiliation(50, 100.50); e.Affiliation = af; int memeberId = 86; PayrollDb.AddUnionMember(memeberId, e); app.ExexcuteTransaction("addServiceCharge", RequestFactory.rf.MakeServiceChargeRequest(memeberId, new DateTime(2005, 8, 8), 12.95)); ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8)); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Amount, .001); }
protected override void RecordMembership(Employee e) { Affiliation affiliation = PayrollFactory.paymentFactory.MakeUnionAffiliation(e.Affiliation); if (affiliation != null && affiliation.MemberId != null) { int memberId = affiliation.MemberId.Value; PayrollDb.RemoveUnionMember(memberId); } }
public void Execute() { Employee e = PayrollDb.GetEmployee(empId); if (e != null) { Change(e); } else { throw new InvalidOperationException("No such employee."); } }
public void DeleteEmployee() { int empId = 4; app.ExexcuteTransaction("addCommissionedEmployee", RequestFactory.rf.MakeCommissionedEmployeeRequest(empId, "Bill", "Home", 3.2, 500)); Employee e = PayrollDb.GetEmployee(empId); Assert.IsNotNull(e); app.ExexcuteTransaction("deleteEmployee", RequestFactory.rf.MakeDeleteEmployeeRequest(empId)); e = PayrollDb.GetEmployee(empId); Assert.IsNull(e); }
public void Execute() { List <int> empIds = PayrollDb.GetAllEmployeeIds(); foreach (int empId in empIds) { Employee employee = PayrollDb.GetEmployee(empId); if (employee.IsPayDate(payDate)) { PayCheck pc = new PayCheck(payDate); employee.Payday(pc); paychecks[empId] = pc; } } }
public void Execute() { PaymentClassification pc = MakeClassification(); PaymentSchedule ps = MakeSchedule(); PaymentMethod pm = MakeMethod(); Employee e = new Employee(empid, name, address); e.Classification = pc; e.Schedule = ps; e.Method = pm; e.Affiliation = MakeAffiliation(); PayrollDb.AddEmployee(empid, e); }
public void TestAddCommissionedEmployee() { int empId = 1; app.ExexcuteTransaction("addCommissionedEmployee", RequestFactory.rf.MakeCommissionedEmployeeRequest(empId, "Bob", "Home", 0.5, 1000)); Employee e = PayrollDb.GetEmployee(empId); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is CommissionedClassification); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is BiWeeklySchedule); PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
public void TestSalesReceiptTransaction() { int empId = 5; app.ExexcuteTransaction("addCommissionedEmployee", RequestFactory.rf.MakeCommissionedEmployeeRequest(empId, "Bill", "Home", 2.5, 1000)); app.ExexcuteTransaction("addSalesReceipt", RequestFactory.rf.MakeSalesReceiptRequest(new DateTime(2005, 7, 31), 200, empId)); Employee e = PayrollDb.GetEmployee(empId); Assert.IsNotNull(e, "Employee is null"); PaymentClassification pc = e.Classification; Assert.IsTrue(pc is CommissionedClassification); CommissionedClassification cc = pc as CommissionedClassification; SalesReceipt sr = cc.GetSalesReceipt(new DateTime(2005, 7, 31)); Assert.IsNotNull(sr, "Sales receipt is null"); Assert.AreEqual(200, sr.Amount); }
public void TestTimeCardTransaction() { int empId = 5; app.ExexcuteTransaction("addHourlyEmployee", RequestFactory.rf.MakeHourlyEmployeeRequest(empId, "Bob", "Home", 50)); app.ExexcuteTransaction("addTimeCard", RequestFactory.rf.MakeTimeCardRequest(new DateTime(2005, 7, 31), 8.0, empId)); Employee e = PayrollDb.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); }
public void Execute() { Employee e = PayrollDb.GetEmployee(empId); if (e != null) { SalesReceiptHandler srh = e.Classification as SalesReceiptHandler; //CommissionedClassification cc = e.Classification as CommissionedClassification; if (srh != null) { srh.AddSalesReceipt(dateTime, amount); } //cc.AddSalesReceipt(new SalesReceipt(dateTime, amount)); else { throw new InvalidOperationException("Tried to add sales receipt to non-commisioned employee"); } } else { throw new InvalidOperationException("No such employee"); } }
public void Execute() { Employee e = PayrollDb.GetEmployee(empId); if (e != null) { TimeCardHandler tch = e.Classification as TimeCardHandler; //PaymentClassification hc = PayrollFactory.paymentFactory.MakeHourlyClassification(e.Classification); if (tch != null) { tch.AddTimeCard(date, hours); } //hc.AddTimeCard(new TimeCard(date, hours)); else { throw new InvalidOperationException("Tried to add timecard to non-hourly employee"); } } else { throw new InvalidOperationException("No such employee."); } }
public void Execute() { Employee e = PayrollDb.GetUnionMember(memberId); if (e != null) { ServiceChargeHandler sch = e.Affiliation as ServiceChargeHandler; if (sch != null) { sch.AddServiceCharge(time, charge); } //ua.AddServiceCharge(new ServiceCharge(time, charge)); else { throw new InvalidOperationException("Tries to add service charge to union" + "member without a union affiliation"); } } else { throw new InvalidOperationException( "No such union member."); } }
public void Execute() { PayrollDb.DeleteEmployee(id); }
protected override void RecordMembership(Employee e) { PayrollDb.AddUnionMember(memberId, e); }