public async Task AddCustomerAsync_WithValidCustomerModel_AddsNewRecordIntoDb() { // Arrange using (var context = await RepositoryTestHelper.GetInMemoryCustomerDbContext("AddTest1Db")) { var customerRepository = new CustomerRepository(context); var newCustomer = new CustomerModel { FirstName = "Alan", LastName = "Turing", DateOfBirth = new DateTime(1912, 6, 23) }; var expectedResult = RepositoryTestHelper.GetMockCustomerData() .ToList(); expectedResult.Add(new CustomerEntity { Id = 5, FirstName = newCustomer.FirstName, LastName = newCustomer.LastName, DateOfBirth = newCustomer.DateOfBirth } ); // Act await customerRepository.AddCustomerAsync(newCustomer); var result = await customerRepository.GetAllCustomersAsync(); // Assert result.Should().BeEquivalentTo(expectedResult); } }
/// <summary> /// Test Unit to Save Costumer /// </summary> /// <returns></returns> public async Task <int> SaveModelsAsyncTest() { try { CustomerModel model = new CustomerModel( 1, "Moises", "92972566", "Luanda", "*****@*****.**", DateTime.Now, "computador", DateTime.Now, "Root", 1); int i = await customerRepository.AddCustomerAsync(model); if (i != 0) { return(i); } return(0); } catch { return(0); } }
public async Task <int> AddCustomer(CustomerModel model) { if (string.IsNullOrWhiteSpace(model.Name)) { return(0); } try { int i = await customerRepository.AddCustomerAsync(model); if (i != 0) { return(i); } return(0); } catch { Logger.AddToLog("Add Costumer Controller", "Mysql, error on Add Model to Repository"); Logger.WriteLog(); return(0); } }
public async Task AddCustomerAsync(Cor.Models.Customer customer) { await customerRepository.AddCustomerAsync(customer); }