public override void Run(object context) { DbController dbc = new DbController(Connection); try { Category category = (Category)ObjectFactory.Create(ObjectType.Category); dbc.AddCategory(category); Category result = dbc.GetCategory(category.CategoryId); if (result == null) { Fail("Failed to insert new Category record"); return; } else if (!category.Equals(result)) { Fail("Inserted Category record having inconsistent data"); return; } category = (Category)ObjectFactory.Create(ObjectType.Category); category.CategoryId = result.CategoryId; dbc.UpdateCategory(category); result = dbc.GetCategory(category.CategoryId); if (!category.Equals(result)) { Fail("Failed to update Category record"); return; } dbc.DeleteCategory(category.CategoryId); if (dbc.GetCategory(category.CategoryId) != null) { Fail("Failed to delete Category record"); } } catch (Exception e) { Fail(e); } finally { base.Run(context); } }
public override void Run(object context) { DbController dbc = new DbController(Connection); try { Category category = (Category)ObjectFactory.Create(ObjectType.Category); dbc.AddCategory(category); Category result = dbc.GetCategory(category.CategoryId); if (result == null) { Fail("Failed to insert new Category record"); return; } else if (!category.Equals(result)) { Fail("Inserted Category record having inconsistent data"); return; } category = (Category)ObjectFactory.Create(ObjectType.Category); category.CategoryId = result.CategoryId; dbc.UpdateCategory(category); result = dbc.GetCategory(category.CategoryId); if (!category.Equals(result)) { Fail("Failed to update Category record"); return; } dbc.DeleteCategory(category.CategoryId); if (dbc.GetCategory(category.CategoryId) != null) Fail("Failed to delete Category record"); } catch (Exception e) { Fail(e); } finally { base.Run(context); } }
public override void Run(object context) { DbController dbc = new DbController(Connection); try { dbc.DeleteCategory(dbc.GetRandomProduct().Category.CategoryId); Fail("Product constraint violation exception should have occurred"); } catch (Exception e) { Log(e); } finally { base.Run(context); } }