Files
chapter-organizer/Tests/Parsers/EventOccurrence/LineClassifier_Tests.cs
T
poprhythm 19e5ef0675 Enhance event occurrence parsing to skip unmatched high school section headers
This commit introduces a new property to track skipped high school section headers in the EventOccurrenceParseResult and EventOccurrenceParserResult classes. The EventOccurrenceParser has been updated to gracefully skip HS section headers that do not match any event definitions, improving the parsing logic. Additionally, the LocationParsingConfiguration has been removed from the EventOccurrenceParser, simplifying its constructor. Unit tests have been updated to reflect these changes and ensure correct behavior during parsing.
2026-01-09 00:14:19 -05:00

81 lines
2.6 KiB
C#

using Core.Parsers.EventOccurrence;
using NUnit.Framework;
namespace Tests.Parsers.EventOccurrence;
[TestFixture]
public class LineClassifier_Tests
{
[Test]
public void IsEmptyLine_EmptyString_ReturnsTrue()
{
// Act & Assert
Assert.That(LineClassifier.IsEmptyLine(""), Is.True);
}
[Test]
public void IsEmptyLine_WhitespaceOnly_ReturnsTrue()
{
// Act & Assert
Assert.That(LineClassifier.IsEmptyLine(" "), Is.True);
Assert.That(LineClassifier.IsEmptyLine("\t\n"), Is.True);
}
[Test]
public void IsEmptyLine_NonEmpty_ReturnsFalse()
{
// Act & Assert
Assert.That(LineClassifier.IsEmptyLine("Some text"), Is.False);
}
[Test]
public void IsCommentLine_StartsWithHash_ReturnsTrue()
{
// Act & Assert
Assert.That(LineClassifier.IsCommentLine("# This is a comment"), Is.True);
}
[Test]
public void IsCommentLine_NoHash_ReturnsFalse()
{
// Act & Assert
Assert.That(LineClassifier.IsCommentLine("Not a comment"), Is.False);
}
[Test]
public void IsContinuationLine_ParentheticalNote_ReturnsTrue()
{
// Act & Assert
Assert.That(LineClassifier.IsContinuationLine("(Semifinalists only)"), Is.True);
Assert.That(LineClassifier.IsContinuationLine("(Note: Some information)"), Is.True);
}
[Test]
public void IsContinuationLine_StartsWithAsterisk_ReturnsTrue()
{
// Act & Assert
Assert.That(LineClassifier.IsContinuationLine("*The books of semifinalist teams"), Is.True);
Assert.That(LineClassifier.IsContinuationLine("*Note: Important details"), Is.True);
Assert.That(LineClassifier.IsContinuationLine("*This is a continuation line"), Is.True);
Assert.That(LineClassifier.IsContinuationLine(" *Line with leading whitespace"), Is.True);
}
[Test]
public void IsContinuationLine_DoesNotStartWithAsterisk_ReturnsFalse()
{
// Act & Assert
Assert.That(LineClassifier.IsContinuationLine("The event will be held"), Is.False);
Assert.That(LineClassifier.IsContinuationLine("Note: Additional information"), Is.False);
Assert.That(LineClassifier.IsContinuationLine("Important Event March 15"), Is.False);
Assert.That(LineClassifier.IsContinuationLine("Schedule Posted on website"), Is.False);
}
[Test]
public void IsContinuationLine_RegularEventLine_ReturnsFalse()
{
// Act & Assert
Assert.That(LineClassifier.IsContinuationLine("Test Event March 15 3:00 p.m. Room A"), Is.False);
}
}