Keep legal first and last names for formal lists; show DisplayFirstName on teams, calendars, and import matching so two Josiahs can be told apart. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using Core.Parsers;
|
|
using Tests.Builders;
|
|
|
|
namespace Tests.Parsers;
|
|
|
|
[TestFixture]
|
|
public class FuzzyStudentMatcher_Tests
|
|
{
|
|
[SetUp]
|
|
public void SetUp() => StudentBuilder.ResetIdCounter();
|
|
|
|
[Test]
|
|
public void Find_MatchesNicknameAmongTwoJosiahs()
|
|
{
|
|
var jo = StudentBuilder.Create("Josiah", "Brown").WithNickname("Jo").Build();
|
|
var josiahB = StudentBuilder.Create("Josiah", "Green").WithNickname("Josiah B").Build();
|
|
|
|
var match = FuzzyStudentMatcher.Find([jo, josiahB], "Jo");
|
|
|
|
Assert.That(match, Is.Not.Null);
|
|
Assert.That(match!.Value.Student.Id, Is.EqualTo(jo.Id));
|
|
}
|
|
|
|
[Test]
|
|
public void Score_LegalNameStillMatchesWhenNicknameSet()
|
|
{
|
|
var jo = StudentBuilder.Create("Josiah", "Brown").WithNickname("Jo").Build();
|
|
|
|
Assert.That(FuzzyStudentMatcher.Score(jo, "Josiah Brown"), Is.GreaterThanOrEqualTo(FuzzyStudentMatcher.MatchThreshold));
|
|
Assert.That(FuzzyStudentMatcher.Score(jo, "Brown, Josiah"), Is.GreaterThanOrEqualTo(FuzzyStudentMatcher.MatchThreshold));
|
|
}
|
|
|
|
[Test]
|
|
public void Score_NullNicknameDoesNotThrow()
|
|
{
|
|
var student = StudentBuilder.Create("Aria", "Cole").Build();
|
|
|
|
Assert.That(FuzzyStudentMatcher.Score(student, "Aria Cole"), Is.GreaterThanOrEqualTo(FuzzyStudentMatcher.MatchThreshold));
|
|
Assert.That(FuzzyStudentMatcher.Find([student], "Nobody"), Is.Null);
|
|
}
|
|
}
|