コード例 #1
0
        public void Should_create_suggestions_for_user_when_it_have_not_in_repository()
        {
            // Arrange
            var compiler = new SummaryCompiler();
            var expected = compiler.Compile(_summaryRepository.Get(), _rule);

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

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count, Is.EqualTo(expected.Count()));
            Assert.That(result.Select(s => s.Summary.Id), Is.EquivalentTo(expected.Select(s => s.Id)));
        }
コード例 #2
0
        private IEnumerable <SummarySuggestion> CompileForVacancy(Int32 vacancyId)
        {
            Vacancy vacancy = _vacancyRepository.Get(vacancyId);

            var compiler = new SummaryCompiler();
            var rule     = new SimpleSummaryRule(vacancy.Specialization, vacancy.Skills);
            IEnumerable <Summary> summaries = compiler.Compile(_summaryRepository.Get(), rule);

            IReadOnlyCollection <SummarySuggestion> summarySuggestions =
                summaries.Select(s => new SummarySuggestion(vacancy, s)).ToList();

            summarySuggestions = _summarySuggestionRepository.Add(summarySuggestions).ToList();
            if (!summarySuggestions.Any())
            {
                throw new ArgumentException("It's no suggestion for vacancy! Change vacancy or try later.");
            }

            return(summarySuggestions);
        }