Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 public async Task <IEnumerable <Company> > ListCompaniesByNameAsync(string name, bool ascending = true)
 {
     return(await companyQueryObject.GetByNameAsync(name, ascending));
 }