public override void Run(object context) { DbController dbc = new DbController(Connection); try { Address address = (Address)ObjectFactory.Create(ObjectType.Address); dbc.AddAddress(address); Supplier supplier = (Supplier)ObjectFactory.Create(ObjectType.Supplier); supplier.Address = address; dbc.AddSupplier(supplier); Supplier result = dbc.GetSupplier(supplier.SupplierId); if (result == null) { Fail("Failed to insert new Supplier record"); return; } else if (!supplier.Equals(result)) { Fail("Inserted Supplier record having inconsistent data"); return; } supplier = (Supplier)ObjectFactory.Create(ObjectType.Supplier); supplier.SupplierId = result.SupplierId; dbc.UpdateSupplier(supplier); result = dbc.GetSupplier(supplier.SupplierId); if (!supplier.Equals(result)) { Fail("Failed to update Supplier record"); return; } dbc.DeleteSupplier(supplier.SupplierId); if (dbc.GetSupplier(supplier.SupplierId) != null) { Fail("Failed to delete Supplier 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); Supplier supplier = (Supplier)ObjectFactory.Create(ObjectType.Supplier); supplier.Address = address; dbc.AddSupplier(supplier); Supplier result = dbc.GetSupplier(supplier.SupplierId); if (result == null) { Fail("Failed to insert new Supplier record"); return; } else if (!supplier.Equals(result)) { Fail("Inserted Supplier record having inconsistent data"); return; } supplier = (Supplier)ObjectFactory.Create(ObjectType.Supplier); supplier.SupplierId = result.SupplierId; dbc.UpdateSupplier(supplier); result = dbc.GetSupplier(supplier.SupplierId); if (!supplier.Equals(result)) { Fail("Failed to update Supplier record"); return; } dbc.DeleteSupplier(supplier.SupplierId); if (dbc.GetSupplier(supplier.SupplierId) != null) Fail("Failed to delete Supplier record"); } catch (Exception e) { Fail(e); } finally { base.Run(context); } }