private void PrepareToSavePaymentClassification(Employee employee) { PaymentClassification paymentClassification = employee.Classification; if (paymentClassification is HourlyClassification) { classificatinCode = "hourly"; HourlyClassification hourlyClassification = paymentClassification as HourlyClassification; CreateInsertHourlyCommand(employee, hourlyClassification); } else if (paymentClassification is SalariedClassification) { classificatinCode = "salaried"; SalariedClassification salariedClassification = paymentClassification as SalariedClassification; CreateInsertSalariedCommand(employee, salariedClassification); } else if (paymentClassification is CommissionClassification) { classificatinCode = "commission"; CommissionClassification commissionClassification = paymentClassification as CommissionClassification; CreatInsertCommissionedCommand(employee, commissionClassification); } else { classificatinCode = "unknown"; } }
public void TestChangeSalariedTransaction() { int empId = 4; AddCommissionEmployee t = new AddCommissionEmployee(empId, "Kubing", "Home", 2500, 3.2, database); t.Execute(); ChangeSalariedTransaction cst = new ChangeSalariedTransaction(empId, 1000.00, database); cst.Execute(); Employee e = database.GetEmployee(empId); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(1000.00, sc.Salary, 0.001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); }
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 TestAddSalariedEmployee() { int empId = 1; AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00); t.Execute(); Employee e = PayrollDatabase.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); // paid on the last working day of the month PaymentMethod pm = e.Method; Assert.IsTrue(pm is HoldMethod); }
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 TestChangeSalariedTransaction() { int empId = 3; AddCommissionedEmployee t = new AddCommissionedEmployee(empId, "Lance", "Home", 2500, 10); t.Execute(); ChangeSalariedTransaction cht = new ChangeSalariedTransaction(empId, 3000); cht.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is SalariedClassification); SalariedClassification hc = pc as SalariedClassification; Assert.AreEqual(3000, hc.Salary, .001); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); }
private void PrepareToSaveClassification(Employee employee) { PaymentClassification classification = employee.Classification; if (classification is HourlyClassification) { classificationCode = "hourly"; HourlyClassification hourlyClassification = classification as HourlyClassification; insertClassificationCommand = CreateInsertHourlyClassificationCommand(hourlyClassification, employee); } else if (classification is SalariedClassification) { classificationCode = "salary"; SalariedClassification salariedClassification = classification as SalariedClassification; insertClassificationCommand = CreateInsertSalariedClassificationCommand(salariedClassification, employee); } else if (classification is CommissionClassification) { classificationCode = "commission"; CommissionClassification commissionClassification = classification as CommissionClassification; insertClassificationCommand = CreateInsertCommissionClassificationCommand(commissionClassification, employee); } else { classificationCode = "unknown"; } }
public void TestAddSalariedEmployee() { int empId = 1; var t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.0M); t.Execute(); var e = Database.GetEmployee(empId); Assert.AreEqual("Bob", e.Name); PaymentClassification pc = e.GetClassification(); SalariedClassification sc = (SalariedClassification)pc; Assert.AreEqual(sc.Salary, 1000.00M); PaymentSchedule ps = e.GetSchedule(); Assert.IsInstanceOfType(ps, typeof(MonthlySchedule)); PaymentMethod pm = e.GetMethod(); Assert.IsInstanceOfType(pm, typeof(HoldMethod)); }
public void TestAddSalariedEmployee() { var empId = 1; AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00, database); t.Execute(); Employee e = database.GetEmployee(empId); Assert.AreEqual(e.Name, "Bob");; 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 LoadSalariedEmployee() { employee.Schedule = new BiweeklySchedule(); employee.Method = new DirectDepositMethod("1st Bank", "0123456"); employee.Classification = new SalariedClassification(5432.10); database.AddEmployee(employee); Employee loadedEmployee = database.GetEmployee(123); Assert.AreEqual(123, loadedEmployee.EmpId); Assert.AreEqual(employee.Name, loadedEmployee.Name); Assert.AreEqual(employee.Address, loadedEmployee.Address); PaymentSchedule schedule = loadedEmployee.Schedule; Assert.IsTrue(schedule is BiweeklySchedule); PaymentMethod method = loadedEmployee.Method; Assert.IsTrue(method is DirectDepositMethod); DirectDepositMethod ddMethod = method as DirectDepositMethod; Assert.AreEqual("1st Bank", ddMethod.Bank); Assert.AreEqual("0123456", ddMethod.Account); PaymentClassification classification = loadedEmployee.Classification; Assert.IsTrue(classification is SalariedClassification); SalariedClassification salariedClassification = classification as SalariedClassification; Assert.AreEqual(5432.10, salariedClassification.Salary, .01); }
public void TestAddSalariedEmployee() { int empId = 1; AddSalariedEmployee t = new AddSalariedEmployee(empId, "Kubing", "Home", 1000.00, database); t.Execute(); Employee e = database.GetEmployee(empId); Assert.That("Kubing", Is.EqualTo(e.Name)); PaymentClassification pc = e.Classification; Assert.That(pc is SalariedClassification, Is.True); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(1000.00, sc.Salary, .001); PaymentSchedule ps = e.Schedule; Assert.That(ps is MonthlySchedule, Is.True); PaymentMethod pm = e.Method; Assert.That(pm is HoldMethod, Is.True); }
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); }
private SqlCommand CreateInsertSalariedClassificationCommand(SalariedClassification classification, Employee employee) { string sql = "insert into SalariedClassification values (@Salary, @EmpId)"; SqlCommand command = new SqlCommand(sql); command.Parameters.Add("@Salary", classification.Salary); command.Parameters.Add("@EmpId", employee.EmpId); return(command); }
private void CreateInsertSalariedCommand(Employee employee, SalariedClassification salariedClassification) { string sql = "insert into SalariedClassification " + "values (@Salary, @EmpId)"; insertPaymentClassificationCommand = new SqlCommand(sql); insertPaymentClassificationCommand.Parameters.AddWithValue("@Salary", salariedClassification.Salary); insertPaymentClassificationCommand.Parameters.AddWithValue("@EmpId", employee.EmpId); }
private void SetPaymentClassification() { PaymentClassification classification = employee.Classfication; if (classification is HourlyClassification) { classificationCode = "hourly"; HourlyClassification hourlyClassification = classification as HourlyClassification; insertClassificationSql = "insert into HourlyClassification values " + "(@HourlyRate, @EmpId)"; classificationParameters = new object[] { hourlyClassification.HourlyRate, employee.EmpId }; } else if (classification is SalariedClassification) { classificationCode = "salary"; SalariedClassification salariedClassification = classification as SalariedClassification; insertClassificationSql = "insert into SalariedClassification values (@Salary, @EmpId)"; classificationParameters = new object[] { salariedClassification.Salary, employee.EmpId }; } else if (classification is CommissionClassification) { classificationCode = "commission"; CommissionClassification commissionClassification = classification as CommissionClassification; insertClassificationSql = "insert into CommissionedClassification values " + "(@Salary, @Commission, @EmpId)"; classificationParameters = new object[] { commissionClassification.BaseRate, commissionClassification.CommissionRate, employee.EmpId }; } else { classificationCode = "unknown"; } }
public void CreateSalariedClassificationFromRow() { operation = new LoadPaymentClassificationOperation(employee, "salary", null); operation.Prepare(); DataRow row = LoadEmployeeOperationTest.ShuntRow("Salary", 2500.00); operation.CreateClassification(row); PaymentClassification classification = this.operation.Classification; Assert.IsTrue(classification is SalariedClassification); SalariedClassification salariedClassification = classification as SalariedClassification; Assert.AreEqual(2500.00, salariedClassification.Salary, 0.01); }
public void CreateSalariedClassificationFromRow() { operation = new LoadClassificationOperation(employee, "salaried", null); operation.Prepare(); DataRow row = LoadEmployeeOperationTest.ShuntRow("Salary", "1254.25"); operation.CreateClassification(row); PaymentClassification classification = operation.Classification; Assert.IsTrue(classification is SalariedClassification); SalariedClassification salariedClassification = classification as SalariedClassification; Assert.AreEqual(1254.25, salariedClassification.Salary); }
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 TestAddSalariedEmployee() { int empId = 1; AddSalariedEmployee t = new AddSalariedEmployee(empId, "Bob", "Home", 1000.00); t.Execute(); Employee emp = PayrollDatabase.GetEmployee(empId); Assert.AreEqual("Bob", emp.Name); PaymentClassification pc = emp.Classification; Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; PaymentSchedule ps = emp.Schedule; PaymentMethod pm = emp.Method; }
public void ExecuteTest() { int empId = 23; double salary = 1600; AddEmployeeTransaction addHourlyEmp = new AddHourlyEmployee(empId, "kara", "samubola", 3000, database); addHourlyEmp.Execute(); ChangeClassificationTranscation changeHourlyTrans = new ChangeSalariedTransaction(empId, salary, database); changeHourlyTrans.Execute(); Employee emp = database.GetEmployee(empId); Assert.IsNotNull(emp); Assert.IsTrue(emp.Classification is SalariedClassification); SalariedClassification hc = emp.Classification as SalariedClassification; Assert.IsNotNull(hc); Assert.AreEqual(hc.Salary, salary); }
public void ExecuteTest() { AddEmployeeTransaction addEmp = new AddSalariedEmployee(1, "Bob", "Street Lasa", 1800, database); addEmp.Execute(); Employee emp = database.GetEmployee(1); Assert.IsNotNull(emp); PaymentClassification classifiction = emp.Classification; PaymentMethod method = emp.Method; PaymentSchedule schedule = emp.Schedule; Assert.AreEqual("Bob", emp.Name); Assert.IsTrue(classifiction is SalariedClassification); Assert.IsTrue(method is HoldMethod); Assert.IsTrue(schedule is MonthlySchedule); SalariedClassification salaryClassifiction = classifiction as SalariedClassification; //as 不会报错,只会返回空 Assert.AreEqual(1800, salaryClassifiction.Salary, 0.0001); }
public void TestAddSalariedEmployee() { int empId = 1; AddSalariedEmployee t = new AddSalariedEmployee(empId, "Йорик", "Гочина 23", 2000.00); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.AreEqual("Йорик", e.name); PaymentClassification pc = e.classification; Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(2000.00, sc.Salary, .001); PaymentSchedule ps = e.schedule; Assert.IsTrue(ps is MonthlySchedule); PaymentMethod pm = e.method; Assert.IsTrue(pm is HoldMethod); }
public void AddSalaryEmployee() { int emplid = 1; string address = "1st street"; string fullName = "Kyle"; decimal salary = 10.0m; AddEmployeeTransaction t = new AddSalariedEmployee(emplid, address, fullName, salary); t.Execute(); Employee e = Database.GetEmployee(emplid); Assert.AreEqual(emplid, e.Emplid); Assert.AreEqual(address, e.Address); Assert.AreEqual(fullName, e.FullName); CheckEmployeePaymentTypes(typeof(SalariedClassification), typeof(HoldMethod), typeof(MonthlySchedule), e); SalariedClassification sc = e.paymentClassification as SalariedClassification; Assert.AreEqual(salary, sc.Salary); }
public void AddSalariedEmployee() { int empid = 3; AddSalariedEmployee t = new AddSalariedEmployee(empid, "Bob", "Home", 1000.00); t.Execute(); Employee e = PayrollDatabase.instance.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 ChangeSalariedTransaction() { int empid = 12; AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 23.41); t.Execute(); ChangeSalariedTransaction cht = new ChangeSalariedTransaction(empid, 20.44); cht.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.IsNotNull(e); PaymentClassification pc = e.Classification; Assert.IsNotNull(pc); Assert.IsTrue(pc is SalariedClassification); SalariedClassification sc = pc as SalariedClassification; Assert.AreEqual(20.44, sc.Salary); PaymentSchedule ps = e.Schedule; Assert.IsTrue(ps is MonthlySchedule); }