public void Should_create_suggestions_for_user_when_it_have_not_in_repository()
        {
            // Arrange
            var compiler = new VacancyCompiler();
            var expected = compiler.Compile(_vacancyRepository.Get(), _rule);

            // Act
            var result = _vacancySuggestionService.SuggestAllForUser(0);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(expected.Count()));
            Assert.That(result.Select(s => s.Vacancy.Id), Is.EquivalentTo(expected.Select(s => s.Id)));
        }
예제 #2
0
        private IEnumerable <VacancySuggestion> CompileForSummary(Int32 summaryId)
        {
            Summary summary = _summaryRepository.Get(summaryId);

            var compiler = new VacancyCompiler();
            var rule     = new SimpleVacancyRule(summary.Specialization, summary.Skills);
            IEnumerable <Vacancy> summaries = compiler.Compile(_vacancyRepository.Get(), rule);

            IReadOnlyCollection <VacancySuggestion> vacancySuggestions =
                summaries.Select(s => new VacancySuggestion(summary, s)).ToList();

            vacancySuggestions = _vacancySuggestionRepository.Add(vacancySuggestions).ToList();

            if (!vacancySuggestions.Any())
            {
                throw new ArgumentException("It's no suggestion for summary! Change summary or try later.");
            }

            return(vacancySuggestions);
        }