public override void Run(object context) { DbController dbc = new DbController(Connection); try { Address address = (Address)ObjectFactory.Create(ObjectType.Address); dbc.AddAddress(address); Customer customer = (Customer)ObjectFactory.Create(ObjectType.Customer); customer.Address = address; dbc.AddCustomer(customer); Customer result = dbc.GetCustomer(customer.CustomerId); if (result == null) { Fail("Failed to insert new Customer record"); return; } else if (!customer.Equals(result)) { Fail("Inserted Customer record having inconsistent data"); return; } customer = (Customer)ObjectFactory.Create(ObjectType.Customer); customer.CustomerId = result.CustomerId; dbc.UpdateCustomer(customer); result = dbc.GetCustomer(customer.CustomerId); if (!customer.Equals(result)) { Fail("Failed to update Customer record"); return; } dbc.DeleteCustomer(customer.CustomerId); if (dbc.GetCustomer(customer.CustomerId) != null) { Fail("Failed to delete Customer record"); } } catch (Exception e) { Fail(e); } finally { base.Run(context); } }
public override void Run(object context) { DbController dbc = new DbController(Connection); try { Address address = (Address)ObjectFactory.Create(ObjectType.Address); dbc.AddAddress(address); Customer customer = (Customer)ObjectFactory.Create(ObjectType.Customer); customer.Address = address; dbc.AddCustomer(customer); Customer result = dbc.GetCustomer(customer.CustomerId); if (result == null) { Fail("Failed to insert new Customer record"); return; } else if (!customer.Equals(result)) { Fail("Inserted Customer record having inconsistent data"); return; } customer = (Customer)ObjectFactory.Create(ObjectType.Customer); customer.CustomerId = result.CustomerId; dbc.UpdateCustomer(customer); result = dbc.GetCustomer(customer.CustomerId); if (!customer.Equals(result)) { Fail("Failed to update Customer record"); return; } dbc.DeleteCustomer(customer.CustomerId); if (dbc.GetCustomer(customer.CustomerId) != null) Fail("Failed to delete Customer record"); } catch (Exception e) { Fail(e); } finally { base.Run(context); } }