public void CompanyQueryObjectTest() { // Companies var unitOfWork = new UnitOfWork(GetInMemoryOptions()); Seeder.Seed(unitOfWork); var x = unitOfWork.CompanyRepository.GetAll(); Assert.Equal(4, unitOfWork.CompanyRepository.GetAll().Count()); var companiesQueryObject = new CompanyQueryObject(unitOfWork); Assert.Equal(new List <string>() { "Apple" }, companiesQueryObject.GetByNameAsync("Apple") .Result .Select(c => c.Name)); Assert.Equal(new List <string>() { "Tesla" }, companiesQueryObject.GetByNameAsync("Tesla") .Result .Select(c => c.Name)); Assert.Equal(new List <string>() { "Apple", "Tesla" }, companiesQueryObject.GetByNameContainsAsync("l") .Result .Select(c => c.Name)); Assert.Equal(new List <string>() { "Tesla", "Apple" }, companiesQueryObject.GetByNameContainsAsync("l", false) .Result .Select(c => c.Name)); unitOfWork.Dispose(); }
public async Task <IEnumerable <Company> > ListCompaniesByNameContainsAsync(string name, bool ascending = true) { return(await companyQueryObject.GetByNameContainsAsync(name, ascending)); }