//map DMCustomer to Entity customer private Core.Entities.Customer MapCustomerToCoreCustomer(DMCustomer customer, Guid userGuid) { customerEntity = new Entities.Customer(); customerEntity.CustomerGuid = Guid.NewGuid(); customerEntity.CustomerName = customer.CustomerName.Trim(); customerEntity.CustomerTypeGuid = customer.CustomerTypeGuid; customerEntity.Department = customer.Department; customerEntity.Agency = customer.Agency.Trim(); customerEntity.CustomerDescription = customer.CustomerDescription; customerEntity.Address = customer.Address; customerEntity.AddressLine1 = customer.AddressLine1; customerEntity.City = customer.City; customerEntity.ZipCode = customer.ZipCode; customerEntity.PrimaryPhone = customer.PrimaryPhone; customerEntity.PrimaryEmail = customer.PrimaryEmail; customerEntity.Abbreviations = customer.Abbreviations; customerEntity.Tags = customer.Tags; customerEntity.CustomerCode = customer.CustomerCode; customerEntity.Url = customer.Url; customerEntity.StateId = customer.StateId; customerEntity.CountryId = customer.CountryId; customerEntity.CreatedOn = DateTime.UtcNow; customerEntity.IsActive = true; customerEntity.IsDeleted = false; customerEntity.CreatedBy = userGuid; customerEntity.UpdatedBy = userGuid; customerEntity.UpdatedOn = DateTime.UtcNow; customerEntity.CustomerTypeName = customer.CustomerType; customerEntity.Department = customer.Department; customerEntity.Agency = customer.Agency; customerEntity.CustomerDescription = customer.CustomerDescription; return(customerEntity); }
public async void GetCompanies_PageSizeIsThree_ReturnsOneCompany() { // Arrange var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = ":memory:" }; var connection = new SqliteConnection(connectionStringBuilder.ConnectionString); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseSqlite(connection) .Options; using (var context = new ApplicationDbContext(options)) { context.Database.OpenConnection(); context.Database.EnsureCreated(); var customer = new Core.Entities.Customer() { Id = new Guid(), Name = "Jorge", Email = "*****@*****.**", Stage = true, Type = 1 }; context.Customer.Add(customer); context.Company.Add(new Core.Entities.Company() { CustomerId = customer.Id, Name = "Empresa do Jorger", Cnpj = "99999999999999" }); context.SaveChanges(); } using (var context = new ApplicationDbContext(options)) { var companyRepository = new CompanyRepository(context); // Act var companies = await companyRepository.GetCompanies(1, 3); // Assert Assert.Equal(1, companies.Count); } }
public async Task ListAsync_ReturnsObjects( [Frozen] Mock <AWContext> mockContext, string userId, string userName, Core.Entities.Customer customer, string shipMethod, Core.ValueTypes.Address address, Core.Entities.CreditCard creditCard, string cardSecurityNumber, string cardHolderName ) { //Arrange creditCard.ExpYear = short.Parse(DateTime.Today.Year.ToString()); creditCard.ExpMonth = byte.Parse(DateTime.Today.Month.ToString()); var salesOrders = new List <Core.Entities.SalesOrder>(); int orderCount = 2; for (int i = 0; i < orderCount; i++) { salesOrders.Add( new Core.Entities.SalesOrder( userId, userName, customer, shipMethod, address, address, creditCard, cardSecurityNumber, cardHolderName ) ); } var mockSet = salesOrders.AsQueryable().BuildMockDbSet(); mockContext.Setup(x => x.Set <Core.Entities.SalesOrder>()) .Returns(mockSet.Object); var repository = new EfRepository <Core.Entities.SalesOrder>(mockContext.Object); //Act var spec = new GetSalesOrdersForCustomerSpecification(salesOrders[0].Customer.CustomerNumber); var list = await repository.ListAsync(spec); //Assert list.Count.Should().Be(orderCount); }
//Update customer to DB private bool UpdateCustomerToDb(Core.Entities.Customer customer) { _customerService.Edit(customer); return(true); }