Пример #1
0
        public async Task SearchTest()
        {
            Vacancy vacancy1 = new Vacancy()
            {
                Id = 22,

                Status = 1,

                ProjectName = "Some project name",

                City = 4
            };

            Vacancy vacancy2 = new Vacancy()
            {
                Id = 2,

                Status = 4,

                ProjectName = "Another project name",

                City = 2
            };

            VacancySearchModel searchModel = new VacancySearchModel()
            {
                VacancyName = "JavaScript Junior Developer",

                City = 3,

                Status = 2,

                RequestDate = new DateTime(2017, 8, 8)
            };

            IQueryable <Vacancy> vacancyFindList = new List <Vacancy>().AsQueryable();

            IQueryable <Vacancy> vacancyReadList = new List <Vacancy>()
            {
                vacancy1, vacancy2
            }.AsQueryable();

            mockVacancyRepository.Setup(x => x.Find(It.IsAny <VacancySearchModel>())).Returns(vacancyFindList);

            mockVacancyRepository.Setup(x => x.ReadAll()).Returns(vacancyReadList);

            var candidateRepository = mockCandidateRepository.Object;

            var unitOfWork = mockUnitOfWork.Object;

            var candidateService = mockCandidateService.Object;

            var techSkillRepository = mockTechSkillRepository.Object;

            var vacancyRepository = mockVacancyRepository.Object;

            var eventService = mockEventService.Object;

            var vacancyService = new VacancyService(unitOfWork, vacancyRepository, candidateRepository, techSkillRepository,
                                                    candidateService, eventService);

            var result = await vacancyService.Search(0, 5, searchModel, null);

            Assert.AreEqual(0, result.Count);

            var actual = await vacancyService.Search(0, 5, null, null);

            Assert.AreEqual(2, actual.Count);
        }