コード例 #1
0
        public async Task WhenInvoked_ItShouldReturnTheExpectedScore(string phrase, int expectedScore, decimal weighting = 1.0m)
        {
            var rule = new VacancyProfanityChecksRule(new TestProfanityListProvider(), ConsolidationOption.ConsolidateByField, weighting);

            var entity = TestVacancyBuilder.Create().SetTitle(phrase);

            var outcome = await rule.EvaluateAsync(entity);

            Assert.Equal(expectedScore, outcome.Score);
        }
コード例 #2
0
        public void WhenInvoked_ItShouldReturnTheExpectedScore(string phrase, int expectedScore,
                                                               decimal weighting = 1.0m)
        {
            var rule = new VacancyBannedPhraseChecksRule(_bannedPhrasesProvider, ConsolidationOption.ConsolidateByField, weighting);

            var entity = TestVacancyBuilder.Create().SetDetails(phrase, string.Empty);

            var outcome = rule.EvaluateAsync(entity).Result;

            outcome.Score.Should().Be(expectedScore);
        }
コード例 #3
0
        public async Task WhenInvoked_ItShouldReturnTheExpectedScore(string apprenticeshipTitle, int expectedScore)
        {
            var rule = new VacancyTitlePopularityCheckRule(_mockApprenticeshipProgrammesProvider.Object, _mockGetTitlePopularityService.Object, _qaRulesConfig);

            var entity = TestVacancyBuilder
                         .Create()
                         .SetTitle(apprenticeshipTitle)
                         .SetTrainingProgrammeId(TrainingLarsCode);

            var outcome = await rule.EvaluateAsync(entity);

            outcome.Score.Should().Be(expectedScore);
        }
コード例 #4
0
        public async Task WhenInvoked_ItShouldSetTheCorrectDetailsDataType()
        {
            var rule = new VacancyTitlePopularityCheckRule(_mockApprenticeshipProgrammesProvider.Object, _mockGetTitlePopularityService.Object, _qaRulesConfig);

            var entity = TestVacancyBuilder
                         .Create()
                         .SetTitle(ApprenticeTitle1)
                         .SetTrainingProgrammeId(TrainingLarsCode);

            var outcome = await rule.EvaluateAsync(entity);

            outcome.Details.First().Data.Should().BeOfType(typeof(string));
        }
コード例 #5
0
        public void ShouldReturnAnOverallConsolidatedNarrative()
        {
            var rule = new VacancyBannedPhraseChecksRule(_bannedPhrasesProvider, ConsolidationOption.ConsolidateByField);

            var skills = new[] { "Juggling", "Running", "driving license" };

            var entity = TestVacancyBuilder.Create()
                         .SetDetails("driving - license required", "must be over 18 years of age and hold a clean driving license, yes a driving license!")
                         .SetSkills(skills);

            var outcome = rule.EvaluateAsync(entity).Result;

            outcome.Narrative.Should().Contain("1 banned phrases 'driving license' found in 'Title'");
            outcome.Narrative.Should().Contain("3 banned phrases 'driving license,over 18' found in 'Description'");
            outcome.Narrative.Should().Contain("1 banned phrases 'driving license' found in 'Skills'");
        }
コード例 #6
0
        public async Task WhenInvoked_ItShouldReturnAnOverallConsolidatedNarrative()
        {
            var rule = new VacancyProfanityChecksRule(new TestProfanityListProvider(), ConsolidationOption.ConsolidateByField);

            var skills = new[] { "Juggling", "Running", "dang" };

            var entity = TestVacancyBuilder.Create()
                         .SetTitle("bother-bother, bother!")
                         .SetDescription("dang it and balderdash!!")
                         .SetSkills(skills);

            var outcome = await rule.EvaluateAsync(entity);

            Assert.Contains("3 profanities 'bother' found in 'Title'", outcome.Narrative);
            Assert.Contains("2 profanities 'dang,balderdash' found in 'Description'", outcome.Narrative);
            Assert.Contains("1 profanities 'dang' found in 'Skills'", outcome.Narrative);
        }
コード例 #7
0
        public void WhenInvoked_ItShouldIncludeDetailsOfEachFieldOutcome()
        {
            var rule = new VacancyBannedPhraseChecksRule(_bannedPhrasesProvider);

            var skills = new[] { "Juggling", "Running", "driving license" };

            var entity = TestVacancyBuilder.Create()
                         .SetDetails("an apprenticeship", "must be over 18 years of age and hold a clean driving license")
                         .SetSkills(skills);

            var outcome = rule.EvaluateAsync(entity).Result;

            outcome.HasDetails.Should().BeTrue();

            Assert.All(outcome.Details, a =>
            {
                a.Target.Should().NotBeEmpty();
                a.Narrative.Should().NotBeEmpty();
            });
        }
コード例 #8
0
        public async Task WhenInvoked_ItShouldIncludeDetailsOfEachFieldOutcome()
        {
            var rule = new VacancyProfanityChecksRule(new TestProfanityListProvider());

            var skills = new[] { "Juggling", "Running", "dang" };

            var entity = TestVacancyBuilder.Create()
                         .SetTitle("bother-bother, bother!")
                         .SetDescription("dang it and balderdash!!")
                         .SetSkills(skills);

            var outcome = await rule.EvaluateAsync(entity);

            Assert.True(outcome.HasDetails);
            Assert.Equal(18, outcome.Details.Count());

            Assert.All(outcome.Details, a =>
            {
                Assert.NotEmpty(a.Target);
                Assert.NotEmpty(a.Narrative);
                Assert.Equal(RuleId.ProfanityChecks, a.RuleId);
            });
        }