public void TestAddServiceChargeTransaction() { // Arrange var employeeId = 1; var employeeName = "Bogdan"; var employeeAddress = "Address"; var hourlyRate = 25; new AddHourlyEmployeeTransaction(employeeId, employeeName, employeeAddress, hourlyRate).Execute(); var employee = payrollRepository.GetEmployee(employeeId); var dues = 12.5; var memberId = 86; var unionAffiliation = new UnionEmployeeAffiliation(memberId, dues); employee.Affiliation = unionAffiliation; payrollRepository.AddUnionMember(memberId, employee); var date = DateTime.Parse("2001-10-31"); var amount = 12.76; // Act new ServiceChargeTransaction(memberId, date, amount).Execute(); var serviceCharge = unionAffiliation.GetServiceCharge(date); // Assert Assert.IsNotNull(serviceCharge); Assert.AreEqual(amount, serviceCharge.Amount); Assert.AreEqual(date, serviceCharge.Date); }
public void TestAddSalesReceiptTransaction() { #region Arrange int employeeId = 5; AddCommissionedEmployee t = new AddCommissionedEmployee(employeeId, "user", "home", 1000, 97.5); t.Execute(); DateTime workingDate = new DateTime(2019, 4, 21); SalesReceiptTransaction srt = new SalesReceiptTransaction( employeeId, workingDate, 200 ); #endregion #region Action srt.Execute(); #endregion #region Assert Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); e.Classification.Should().BeOfType <CommissionedClassification>(); CommissionedClassification cc = e.Classification as CommissionedClassification; SalesReceipt sr = cc.GetSalesReceipt(workingDate); sr.Should().NotBeNull(); sr.Amount.Should().Be(200); #endregion }
public void TestAddServiceCharge() { #region Arrange int employeeId = 9; AddSalariedEmployee asd = new AddSalariedEmployee(employeeId, "user", "home", 1000.0); asd.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); UnionAffiliation af = new UnionAffiliation(); e.Affiliation = af; int memberId = 886; PayrollRepository.AddUnionMember(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction( memberId, new DateTime(2019, 10, 10), 10.0); #endregion #region Action sct.Execute(); #endregion #region Assert ServiceCharge sc = af.GetServiceCharge(new DateTime(2019, 10, 10)); sc.Should().NotBeNull(); sc.Date.Should().Be(new DateTime(2019, 10, 10)); sc.Amount.Should().Be(10.0); #endregion }
public void TestAddCommissionedEmployee() { #region Arrange int empId = 3; string userName = "******"; string address = "Xindian"; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, userName, address, 500.0, 97.5); #endregion #region Action t.Execute(); #endregion #region Assert Employee e = PayrollRepository.GetEmployee(empId); e.Name.Should().Be(userName); e.Address.Should().Be(address); PaymentClassification pc = e.Classification; pc.Should().BeOfType <CommissionedClassification>(); CommissionedClassification cc = pc as CommissionedClassification; cc.Salary.Should().Be(500.0); cc.CommissionedRate.Should().Be(97.5); PaymentSchedule ps = e.Schedule; ps.Should().BeOfType <BiweeklySchedule>(); PaymentMethod pm = e.Method; pm.Should().BeOfType <HoldMethod>(); #endregion }
public void ChangeUnionMember() { int employeeId = 18; AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1); aet.Execute(); int memberId = 8591; ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42); cmt.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); e.Affiliation.Should().NotBeNull(); e.Affiliation.Should().BeOfType <UnionAffiliation>(); UnionAffiliation uf = e.Affiliation as UnionAffiliation; uf.Dues.Should().Be(99.42); Employee member = PayrollRepository.GetUnionMember(memberId); member.Should().NotBeNull(); member.Should().Be(e); }
public void TestAddSalariedEmployee() { #region Arrange int empId = 1; string userName = "******"; AddSalariedEmployee t = new AddSalariedEmployee(empId, userName, "Xindian", 1000.0); #endregion #region Action t.Execute(); #endregion #region Assert Employee e = PayrollRepository.GetEmployee(empId); e.Name.Should().Be(userName); PaymentClassification pc = e.Classification; pc.Should().BeOfType <SalariedClassification>(); SalariedClassification sc = pc as SalariedClassification; sc.Salary.Should().Be(1000.00); PaymentSchedule ps = e.Schedule; ps.Should().BeOfType <MonthlySchedule>(); PaymentMethod pm = e.Method; pm.Should().BeOfType <HoldMethod>(); #endregion }
public void ChangeUnaffiliatedTransaction() { int employeeId = 19; AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1); aet.Execute(); int memberId = 8592; ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42); cmt.Execute(); Employee um = PayrollRepository.GetUnionMember(memberId); um.Should().NotBeNull(); ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(employeeId); cut.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); e.Affiliation.Should().NotBeNull(); e.Affiliation.Should().BeOfType <NoAffiliaction>(); Employee member = PayrollRepository.GetUnionMember(memberId); member.Should().BeNull(); }
public void TestAddTimeCard() { #region Arrange int employeeId = 7; AddHourlyEmployee t = new AddHourlyEmployee(employeeId, "user", "home", 97.5); t.Execute(); DateTime workingDay = new DateTime(2019, 4, 21); TimeCardTransaction tct = new TimeCardTransaction( employeeId, workingDay, 8.0 ); #endregion #region Action tct.Execute(); #endregion #region Assert Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); e.Classification.Should().BeOfType <HourlyClassification>(); HourlyClassification hc = e.Classification as HourlyClassification; TimeCard tc = hc.GetTimeCard(workingDay); tc.Should().NotBeNull(); tc.Hours.Should().Be(8.0); #endregion }
public void TestAddHourlyEmployee() { #region Arrange int empId = 2; string userName = "******"; string address = "Xindian"; AddHourlyEmployee t = new AddHourlyEmployee(empId, userName, address, 97.5); #endregion #region Action t.Execute(); #endregion #region Assert Employee e = PayrollRepository.GetEmployee(empId); e.Name.Should().Be(userName); e.Address.Should().Be(address); PaymentClassification pc = e.Classification; pc.Should().BeOfType <HourlyClassification>(); HourlyClassification hc = pc as HourlyClassification; hc.HourlyRate.Should().Be(97.5); PaymentSchedule ps = e.Schedule; ps.Should().BeOfType <WeeklySchedule>(); PaymentMethod pm = e.Method; pm.Should().BeOfType <HoldMethod>(); #endregion }
public void Execute() { Employee e = PayrollRepository.GetEmployee(_employeeId); if (e != null) { Change(e); } else { throw new InvalidOperationException("No such employee."); } }
public void TestChangeAddressTransaction() { int employeeId = 11; AddEmployTransaction t = new AddHourlyEmployee(employeeId, "Bill", "Home", 15.25); t.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Address.Should().Be("Home"); ChangeAddressTransaction cat = new ChangeAddressTransaction(employeeId, "Company"); cat.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Address.Should().Be("Company"); }
public void Execute() { ArrayList employeeIds = PayrollRepository.GetAllEmployeeIds(); foreach (int eachId in employeeIds) { Employee e = PayrollRepository.GetEmployee(eachId); if (e.IsPayday(_payDate)) { PayCheck pc = new PayCheck(_payDate); _payChecks[eachId] = pc; e.Payday(pc); pc.PayDate = _payDate; } } }
public void TestChangeNameTransaction() { int employeeId = 10; AddEmployTransaction t = new AddHourlyEmployee(employeeId, "Bill", "Home", 15.25); t.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Name.Should().Be("Bill"); ChangeNameTransaction cnt = new ChangeNameTransaction(employeeId, "Bob"); cnt.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Name.Should().Be("Bob"); }
public void TestChangeHoldMethodTransaction() { int employeeId = 17; AddEmployTransaction aet = new AddSalariedEmployee(employeeId, "Bob", "Home", 1000.0); aet.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); ChangeDirectMethodTransaction cdmt = new ChangeDirectMethodTransaction(employeeId, "ctbc", "1234"); cdmt.Execute(); e.Method.Should().BeOfType <DirectMethod>(); ChangeHoldMethodTransaction chmt = new ChangeHoldMethodTransaction(employeeId); chmt.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Method.Should().BeOfType <HoldMethod>(); }
public void TestChangeMailMethodTransaction() { int employeeId = 15; AddEmployTransaction aet = new AddSalariedEmployee(employeeId, "Bob", "Home", 1000.0); aet.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Method.Should().BeOfType <HoldMethod>(); ChangeMailMethodTransation cmmt = new ChangeMailMethodTransation(employeeId, "home"); cmmt.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Method.Should().BeOfType <MailMethod>(); MailMethod mm = e.Method as MailMethod; mm.Address.Should().Be("home"); }
public void TestChangeSalariedTransaction() { int employeeId = 14; AddEmployTransaction ahe = new AddHourlyEmployee(employeeId, "Bill", "Home", 95.0); ahe.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <HourlyClassification>(); ChangeSalariedTransation cst = new ChangeSalariedTransation(employeeId, 1000.0); cst.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <SalariedClassification>(); SalariedClassification sc = e.Classification as SalariedClassification; sc.Salary.Should().Be(1000.0); e.Schedule.Should().BeOfType <MonthlySchedule>(); }
public void TestChangeHourlyTransaction() { int employeeId = 12; AddEmployTransaction AddHourlyEmployee = new AddSalariedEmployee(employeeId, "Bill", "Home", 1000.0); AddHourlyEmployee.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <SalariedClassification>(); ChangeHourlyTransaction cht = new ChangeHourlyTransaction(employeeId, 19.25); cht.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <HourlyClassification>(); HourlyClassification cc = e.Classification as HourlyClassification; cc.HourlyRate.Should().Be(19.25); e.Schedule.Should().BeOfType <WeeklySchedule>(); }
public void TestDeleteEmployee() { #region Arrange int employeeId = 4; AddSalariedEmployee t = new AddSalariedEmployee(employeeId, "user", "home", 1000.0); t.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); DeleteEmployeeTransaction dt = new DeleteEmployeeTransaction(employeeId); #endregion #region Action dt.Execute(); #endregion #region Assert e = PayrollRepository.GetEmployee(employeeId); e.Should().BeNull(); #endregion }
public void TestChangeCommissionedTransaction() { int employeeId = 13; AddEmployTransaction AddHourlyEmployee = new AddSalariedEmployee(employeeId, "Bill", "Home", 1000.0); AddHourlyEmployee.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <SalariedClassification>(); ChangeCommissionedTransaction cct = new ChangeCommissionedTransaction(employeeId, 800.0, 19.25); cct.Execute(); e = PayrollRepository.GetEmployee(employeeId); e.Classification.Should().BeOfType <CommissionedClassification>(); CommissionedClassification cc = e.Classification as CommissionedClassification; cc.Salary.Should().Be(800.0); cc.CommissionedRate.Should().Be(19.25); e.Schedule.Should().BeOfType <BiweeklySchedule>(); }
public void Execute() { Employee e = PayrollRepository.GetEmployee(_employeeId); if (e != null) { HourlyClassification hc = e.Classification as HourlyClassification; bool isHourlyEmployee = hc != null; if (isHourlyEmployee) { hc.AddTimeCard(_employeeId, _workingDate, _workingHours); } else { throw new InvalidOperationException("non-hourly employee"); } } else { throw new InvalidOperationException("No such employee."); } }
public void Execute() { Employee e = PayrollRepository.GetEmployee(_employeeId); bool isValidEmployee = e != null; if (isValidEmployee) { CommissionedClassification cc = e.Classification as CommissionedClassification; bool isCommenssionedEmployee = cc != null; if (isCommenssionedEmployee) { cc.AddSalesReceipt(_employeeId, _workingDate, _amount); } else { throw new InvalidOperationException("non-commenssioned employee"); } } else { throw new InvalidOperationException("No such employee."); } }