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); }
public void EF_Customer_GetCustomer() { using (var cc = new CustomerContext()) { cc.Database.Delete(); cc.Database.Create(); } Left4Edit.Models.Repo.ICustomerRepo repo = new Left4Edit.Models.Repo.EFCustomerRepo(); repo.AddCustomer(CreateTestCustomer_EF().First()); repo.SaveChanges(); var cust = repo.GetCustomer(repo.GetCustomers().First().ID); Assert.IsNotNull(cust); Assert.IsNotNull(cust.Credentials); Assert.IsNotNull(cust.Contacts); Assert.IsNotNull(cust.Nodes); Assert.IsNotNull( cust.Nodes.Where(n => n.Address == "node1.billmcg.com") .First().Credentials ); }
public void EF_Customer_Poco_Add() { using (var cc = new CustomerContext()) { cc.Database.Delete(); cc.Database.Create(); } Left4Edit.Models.Repo.ICustomerRepo repo = new Left4Edit.Models.Repo.EFCustomerRepo(); Customer pocoCustomer = new Customer() { Name = "Poco Inc", Symbol = "POI", Contacts = new List<Contact>() { new Contact() { FirstName = "No way", LastName = "This works!", Email = "*****@*****.**" } } }; repo.AddCustomer(pocoCustomer); repo.SaveChanges(); Assert.IsTrue(repo.GetCustomers().First().Name == "Poco Inc"); Assert.IsTrue(repo.GetCustomers().First().Contacts.First().FirstName == "No way"); }
public void DeleteCustomer_FromPOCO() { 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 existingCustomer = repo.GetCustomers().First(); Customer customerToDelete = new Customer() { ID = existingCustomer.ID, Name = "Test Customer", Symbol = "ASA" }; repo.DeleteCustomer(customerToDelete); repo.SaveChanges(); Assert.IsTrue(repo.GetCustomers().Count() == 0); }