public Customer AddNewCustomer(Customer customer)
 {
     if (FindCustomerByName(customer.Name) is not null)
     {
         throw new Exception("This user already exists in the system.");
     }
     return(_repo.AddNewCustomer(customer));
 }
Exemplo n.º 2
0
 public void AddCustomerShouldAddCustomer()
 {
     using (var context = new Entity.wssdbContext(options))
     {
         CustomerRepoDB _repo = new CustomerRepoDB(context, mapper);
         //Act with a test context
         _repo.AddNewCustomer
         (
             new Model.Customer("Test User")
         );
     }
     //use a diff context to check if changes persist to db
     using (var assertContext = new Entity.wssdbContext(options))
     {
         //Assert with a different context
         var result = assertContext.Customers.FirstOrDefault(cust => cust.Id == 4);
         Assert.NotNull(result);
         Assert.Equal("Test User", result.CName);
     }
 }