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 CreateDirectDepositMethod(DataRow row) { var bank = row["Bank"].ToString(); var account = row["Account"].ToString(); Method = new DirectDepositMethod(bank, account); }
private void SetPaymentMethod() { PaymentMethod method = employee.Method; if (method is HoldMethod) { methodCode = "Hold"; } else if (method is MailMethod) { methodCode = "Mail"; } else if (method is DirectDepositMethod) { methodCode = "direct deposit"; DirectDepositMethod ddMethod = method as DirectDepositMethod; insertPaymentMethodSql = "insert into DirectDepositAccount values " + "(@Bank, @Account, @EmpId)"; methodParameters = new object[] { ddMethod.Bank, ddMethod.AccountNumber, employee.EmpId }; } else { methodCode = "unknown"; } }
private void PrepareToSavePaymentMethod(Employee employee) { PaymentMethod method = employee.Method; if (method is HoldMethod) { methodCode = "hold"; } else if (method is DirectDepositMethod) { methodCode = "directdeposit"; DirectDepositMethod ddMethod = method as DirectDepositMethod; insertPaymentMethodCommand = CreateInsertDirectDepositCommand(ddMethod, employee); } else if (method is MailMethod) { methodCode = "mail"; MailMethod mailMethod = method as MailMethod; insertPaymentMethodCommand = CreateInsertMailMethodCommand(mailMethod, employee); } else { methodCode = "unknown"; } }
private SqlCommand CreateInsertDirectDepositCommand(DirectDepositMethod ddMethod, Employee employee) { string sql = "insert into DirectDepositAccount values (@Bank, @Account, @EmpId)"; SqlCommand command = new SqlCommand(sql); command.Parameters.Add("@Bank", ddMethod.Bank); command.Parameters.Add("@Account", ddMethod.AccountNumber); command.Parameters.Add("@EmpId", employee.EmpId); return(command); }
public void CreateDirectDepositMethodFromRow() { operation = new LoadPaymentMethodOperation(employee, "directdeposit", null); operation.Prepare(); DataRow row = LoadEmployeeOperationTest.ShuntRow("Bank,Account", "1st Bank", "0123456"); operation.CreatePaymentMethod(row); PaymentMethod method = this.operation.Method; Assert.IsTrue(method is DirectDepositMethod); DirectDepositMethod ddMethod = method as DirectDepositMethod; Assert.AreEqual("1st Bank", ddMethod.Bank); Assert.AreEqual("0123456", ddMethod.AccountNumber); }
public void SaveIsTransactional() { var method = new DirectDepositMethod(null, null); employee.Method = method; try { database.AddEmployee(employee); Assert.Fail("An exception needs to occur for this test to work."); } catch (Exception) { } var table = LoadTable("Employee"); Assert.AreEqual(0, table.Rows.Count); }