Skip to content

Commit

Permalink
Bake in value of 70 as the fuzzy cutoff.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGHippo committed Jul 9, 2024
1 parent 9d02989 commit 2af6548
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,65 @@ await filterService.GetFilteredQualifications(null, null, null, AwardingOrganisa
qualifications.Should().NotBeNull();
qualifications.Count.Should().Be(1);
}

[TestMethod]
public async Task
GetFilteredQualifications_PassInQualificationNameThatProducesWeightEqual70_DoesNotReturnQualification()
{
// ReSharper disable once StringLiteralTypo
const string qualificationSearch = "teknical";

const string technicalDiplomaInChildCare = "Technical Diploma in Child Care";

var results = new ContentfulCollection<Qualification>
{
Items = new[]
{
new Qualification(
"EYQ-123",
technicalDiplomaInChildCare,
"CACHE",
4,
"Apr-15",
"Aug-19",
"abc/123/987",
"requirements"),
new Qualification(
"EYQ-123",
"Diploma in Early Years Child Care",
"CACHE",
4,
"Apr-15",
"Aug-19",
"abc/123/987",
"requirements")
}
};

var mockContentfulClient = new Mock<IContentfulClient>();
mockContentfulClient.Setup(x => x.GetEntries(
It.IsAny<QueryBuilder<Qualification>>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(results);

var mockFuzzyAdapter = new Mock<IFuzzyAdapter>();
mockFuzzyAdapter.Setup(a => a.PartialRatio(qualificationSearch, technicalDiplomaInChildCare)).Returns(70);

var mockQueryBuilder = new MockQueryBuilder();
var mockLogger = new Mock<ILogger<ContentfulContentFilterService>>();
var filterService =
new ContentfulContentFilterService(mockContentfulClient.Object, mockFuzzyAdapter.Object, mockLogger.Object)
{
QueryBuilder = mockQueryBuilder
};

var qualifications =
await filterService.GetFilteredQualifications(null, null, null, AwardingOrganisations.Cache,
qualificationSearch);

qualifications.Should().NotBeNull();
qualifications.Should().BeEmpty();
}
}

public class MockQueryBuilder : QueryBuilder<Qualification>
Expand Down

0 comments on commit 2af6548

Please sign in to comment.