public List <CustomerDto> GetCustomers(CustomerPaggingFilterDto dto) { return(_unitOfWork.Customers .OrderCustomersBy(dto.OrderBy, dto.OrderType) .Skip(dto.Skip) .Take(dto.Take) .ProjectTo <CustomerDto>(_mapper.ConfigurationProvider) .ToList()); }
public void GetAllCustomers() { //Arrange var customersFilter = new CustomerPaggingFilterDto( CustomerOrderBy.SimpleOrder, OrderType.Asc, 0, 10); //Act var customers = _customerService.GetCustomers(customersFilter); //Assert Assert.IsNotNull(customers); Assert.AreEqual(7, customers.Count); }
public void GetCustomersByFirstNameDesc() { //Arrange var customersFilter = new CustomerPaggingFilterDto( CustomerOrderBy.FirstName, OrderType.Desc, 0, 10); //Act var customers = _customerService.GetCustomers(customersFilter); var customersDescFromDatabase = _applicationUnitOfWork.Customers .OrderByDescending(c => c.FirstName) .Skip(0) .Take(10) .Select(c => c.FirstName) .ToList(); //Assert Assert.AreEqual(7, customers.Count); Assert.IsTrue(customers.Select(c => c.FirstName).SequenceEqual(customersDescFromDatabase)); }