private msg.Customer GetCustomer(string name, out CRM.Model.Customer model) { using (var scope = host.Create()) { var customers = scope.Get <ICustomerRepository>(); model = customers.Get(name); return(model.CreateDto()); } }
private async Task <CRM.Messages.Customer> CreateCustomer(TestScope scope, string name, string user) { CRM.Model.Customer model; var customers = scope.Get <ICustomerRepository>(); var products = scope.Get <IProductRepository>(); var dto = new CRM.Messages.Customer { Name = name, Company = name, }; model = new CRM.Model.Customer(dto, user, products); customers.Add(model); await customers.SaveChangesAsync(); return(model.CreateDto()); }
public void TestMissingRequiredFieldException() { Func <Task> func = async() => { using (var scope = host.Create()) { string name = "test-error-handling-required-field-violation"; var repo = scope.Get <ICustomerRepository>(); var products = scope.Get <IProductRepository>(); var customer = new CRM.Model.Customer(new CRM.Messages.Customer { Name = name, }, Admin, products); repo.Add(customer); await repo.SaveChangesAsync(); } }; Assert.ThrowsAsync <DbUpdateException>(func); }