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 CreateInsertMailMethodCommand(MailMethod mailMethod, Employee employee) { string sql = "insert into PaycheckAddress values (@Address, @EmpId)"; SqlCommand command = new SqlCommand(sql); command.Parameters.Add("@Address", mailMethod.Address); command.Parameters.Add("@EmpId", employee.EmpId); return(command); }
private void CreateInsertMailMethodCommand(Employee employee, MailMethod mailMethod) { string sql = "insert into PayCheckAddress " + "values (@Address, @EmpId)"; insertPaymentMethodCommand = new SqlCommand(sql); insertPaymentMethodCommand.Parameters.AddWithValue("@Address", mailMethod.Address); insertPaymentMethodCommand.Parameters.AddWithValue("@EmpId", employee.EmpId); }
public void CreateMailMethodFromRow() { operation = new LoadPaymentMethodOperation(employee, "mail", null); operation.Prepare(); DataRow row = LoadEmployeeOperationTest.ShuntRow("Address", "23 Pine Ct"); operation.CreatePaymentMethod(row); PaymentMethod method = this.operation.Method; Assert.IsTrue(method is MailMethod); MailMethod mailMethod = method as MailMethod; Assert.AreEqual("23 Pine Ct", mailMethod.Address); }
public static IMailSender GetSender(MailMethod method = MailMethod.SMTP) { switch (method) { case MailMethod.SMTP: { return new SmtpMailSender(); } case MailMethod.Mandrill: { return new MandrillMailSender(); } default: { return null; } } }
public static IMailAttributes GetAttributes(MailMethod method = MailMethod.SMTP) { switch (method) { case MailMethod.SMTP: { return new SmtpMailAttributes(); } case MailMethod.Mandrill: { return new MandrillMailAttributes(); } default: { return null; } } }
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 AddEmployeeTest_SaveMailMethod_InTransactional() { //Null values won't go in the database. MailMethod method = new MailMethod(null); employee.Method = method; try { database.AddEmployee(employee); Assert.Fail("An exception needs to occur " + "for this test to work"); } catch (SqlException) { } DataTable table = LoadTable("Employee"); Assert.AreEqual(0, table.Rows.Count); }
public void ExecuteTest() { int empId = 28; string mailAddress = "MisStreet"; AddEmployeeTransaction addSalEmp = new AddSalariedEmployee(empId, "kara", "samubola", 3000, database); addSalEmp.Execute(); ChangeMethodTranscation changeMailTrans = new ChangeMailTransaction(empId, mailAddress, database); changeMailTrans.Execute(); Employee emp = database.GetEmployee(empId); Assert.IsNotNull(emp); Assert.IsTrue(emp.Method is MailMethod); MailMethod mailMethod = emp.Method as MailMethod; Assert.IsNotNull(mailMethod); Assert.AreEqual(mailMethod.Address, mailAddress); }
public void TestChangeMailTransaction() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25); t.Execute(); ChangeMailTransaction mt = new ChangeMailTransaction(empId, "email"); mt.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); PaymentMethod pm = e.Method; Assert.IsNotNull(pm); Assert.IsTrue(pm is MailMethod); MailMethod dm = pm as MailMethod; Assert.AreEqual("email", dm.Address); }
public void SetMailMethod(MailMethod method) { MailAttributes = MailMethodUtil.GetAttributes(method); MailSender = MailMethodUtil.GetSender(method); }
private void CreateMailMethod(DataRow row) { var address = row["Address"].ToString(); Method = new MailMethod(address); }