Пример #1
0
 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());
     }
 }
Пример #2
0
        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());
        }
Пример #3
0
        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);
        }