public void UpdateCustomer_FromPOCO() { using (var cc = new CustomerContext()) { cc.Database.Delete(); cc.Database.Create(); } var repo = new Left4Edit.Models.Repo.EFCustomerRepo(); repo.AddCustomer(CreateTestCustomer_Mem().First()); repo.SaveChanges(); // Make sure the POCO customer was accepted Assert.IsTrue(repo.GetCustomers().Count() == 1 && repo.GetCustomers().First().Symbol == "ASA"); var customer = repo.GetCustomers().First(); customer.Name = "Made some Changes!"; repo.AddCredentialToCustomer( new Credential() { Domain = "Update Test", UserName = "******", Password = "******" }, customer.ID ); repo.UpdateCustomer(customer); repo.SaveChanges(); Assert.IsTrue( repo.GetCustomers().First() .Credentials.Where(c => c.Domain == "Update Test") .Count() == 1 ); Assert.IsTrue( repo.GetCustomers().Where(c => c.Name == "Made some Changes!").Count() == 1 ); }
public void UpdateCustomer() { using (var cc = new CustomerContext()) { cc.Database.Delete(); cc.Database.Create(); } var repo = new Left4Edit.Models.Repo.EFCustomerRepo(); repo.AddCustomer(CreateTestCustomer_EF().First()); repo.SaveChanges(); var customer = repo.GetCustomers().First(); Int32 customerKey = customer.ID; String customerName = customer.Name; String newCustomerName = "APPLE SAUCE!"; customer.Name = newCustomerName; repo.UpdateCustomer(customer); repo.SaveChanges(); customer = repo.GetCustomer(customerKey); Assert.IsTrue(customer.Name == newCustomerName); }