protected void Setup() { customer = new Customer(); entityType = typeof(Customer); }
public void AddCustomerToUnitTestDb() { IUnitOfWork uow = facade.GetUnitOfWork(); int numberOfObjectWritten = 0; Customer c = new Customer() { cust_id = "9000", customer = "Whole Foods Market", atten = "Bullwinkle Moose", phone = "618 281 7313" }; if (c.NoErrors) { try { uow.CustomerRepo.Insert(c); uow.Commit(); } catch (DbEntityValidationException e) { CommonTests.CheckDbEntityValidationException(e); } catch (Exception) { //Console.WriteLine("caught exception: {0}", e.Message.ToString()); } finally { numberOfObjectWritten = uow.NumberOfObjectsWritten; facade.ReturnUnitOfWork(); Assert.AreEqual(1, numberOfObjectWritten); } } else { facade.ReturnUnitOfWork(); Assert.Fail("Failed to add object to db"); } }