This commit refactors the EventOccurrence parsing logic to utilize the EventOccurrenceParseGroup class, enhancing the organization of parsed occurrences by grouping them based on event definitions and optional section levels. The changes include updates to the EventOccurrenceParseResult, EventOccurrenceParser, and EventOccurrenceParserService to accommodate the new grouping structure. Additionally, tests are modified to reflect these changes, ensuring that the parsing functionality remains intact and accurate. This refactor improves data handling and aligns with the overall architecture of the application.
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Core.Entities;
|
|
using GoogleSheetsScheduleImport;
|
|
|
|
namespace Tests.GoogleSheets;
|
|
|
|
[TestFixture]
|
|
public class OccurrenceEventMatcherTests
|
|
{
|
|
private static EventDefinition E(string name, int id) =>
|
|
new()
|
|
{
|
|
Id = id,
|
|
Name = name,
|
|
ShortName = name,
|
|
Eligibility = "",
|
|
EventFormat = EventFormat.Team
|
|
};
|
|
|
|
[Test]
|
|
public void Ms_prefix_matches_Biotechnology()
|
|
{
|
|
var events = new List<EventDefinition> { E("Biotechnology", 1), E("Biotechnology Design", 2) };
|
|
var ok = OccurrenceEventMatcher.TryMatch("MS Biotechnology Semifinals Interviews April ...", events, out var evt, out var lvl);
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(ok, Is.True);
|
|
Assert.That(evt!.Name, Is.EqualTo("Biotechnology"));
|
|
Assert.That(lvl, Is.EqualTo(Core.Models.SchoolLevel.MiddleSchool));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void No_Clear_prefix_goes_unmatched_or_general_bucket()
|
|
{
|
|
var events = new List<EventDefinition> { E("Opening Session", 1) };
|
|
var ok = OccurrenceEventMatcher.TryMatch("Opening Session April 10 9 a.m.", events, out var evt, out var lvl);
|
|
Assert.That(ok, Is.False);
|
|
}
|
|
}
|