public Customer CreateWithSpec(string name) { var c = new Customer { Name = name, Description = $"Customer test {name}", CommencementDate = DateTime.Today }; var dp = new DeliveryProduct() { Name = $"DP {new Random().Next(1, 99)}", HasDate = false, Price = 10M, SortOrder = 10, IsNew = true }; c.DeliveryProducts.Add(dp); Action <Customer> action = delegate(Customer cust) { cust.DeliveryProducts.ToList().ForEach(prod => { cmd.SetEntityState <DeliveryProduct, int>(prod); }); }; IDataCommandSpecification <Customer> spec = new CustomerDataCommandSpecification(action); cmd.Create(c); return(c); }
public void Initialize() { var modelBuilder = new CustomerModelBuilder(); ctx = new CustomerDataContext(modelBuilder); cmd = new CustomerDataCommand(ctx); qry = new CustomerDataQuery(ctx); Action <Customer> action = delegate(Customer cust) { cust.DeliveryProducts.ToList().ForEach(prod => { cmd.SetEntityState <DeliveryProduct, int>(prod); }); }; cmdSpec = new CustomerDataCommandSpecification(action); }