Exemplo n.º 1
0
        public CompanyServiceTest()
        {
            _companyRepositoryMock = new Mock <ICompanyRepository>();

            _companyRepositoryMock
            .Setup(p => p.GetCompanies(It.IsAny <SearchCompanies>()))
            .Callback((SearchCompanies s) =>
            {
                if (s.Ids != null && s.Ids.Any())
                {
                    AllCompanies = AllCompanies.Where(p => s.Ids.Contains(p.Id));
                }

                if (s.IsActive != null)
                {
                    AllCompanies = AllCompanies.Where(p => s.IsActive == p.IsActive);
                }
            })
            .ReturnsAsync(AllCompanies);

            _companyRepositoryMock.Setup(p => p.GetCompany(It.IsAny <SearchCompany>()))
            .Callback((SearchCompany filter) =>
            {
            })
            .ReturnsAsync((SearchCompany s) => AllCompanies.FirstOrDefault(company => company.Id == s.Id));

            _companyService = new CompanyService(_companyRepositoryMock.Object);
        }
Exemplo n.º 2
0
        private void FilterList()
        {
            if (FilteredCompanies == null)
            {
                FilteredCompanies = new ObservableCollection <ICompany>();
            }

            FilteredCompanies.Clear();
            if (string.IsNullOrEmpty(FilterString))
            {
                FilteredCompanies.AddRange(AllCompanies);
            }

            else
            {
                var query = AllCompanies.Where(c => c.Name.ToLower().Contains(FilterString.ToLower()) || c.City.ToLower().Contains(FilterString.ToLower()));
                FilteredCompanies.AddRange(query);
            }
        }