Update EventOccurrenceParser to process all events when no school level is set
This commit modifies the EventOccurrenceParser to ensure that when no school level is specified, all events, including high school (HS) events, are processed without filtering. The logic for skipping events based on school level has been simplified, enhancing clarity and maintainability. Corresponding unit tests have been updated to reflect this change, ensuring that HS events are handled appropriately and not incorrectly skipped when no school level is designated.
This commit is contained in:
@@ -577,14 +577,15 @@ public class EventOccurrenceParser_Tests
|
||||
if (constructionChallenge != null && result.Occurrences.ContainsKey(constructionChallenge))
|
||||
msEventCount += result.Occurrences[constructionChallenge].Count;
|
||||
|
||||
// Verify HS events are skipped gracefully (no issues should be created for them)
|
||||
// When no school level is set, HS events should be processed (not skipped)
|
||||
// Verify HS events are processed or handled appropriately
|
||||
var hsIssues = result.Issues.Where(i =>
|
||||
i.LineContent.Contains("Coding – HS") ||
|
||||
i.LineContent.Contains("CAD") && i.LineContent.Contains("HS") ||
|
||||
i.LineNumber >= 72 && i.LineNumber <= 86 && IsHighSchoolEvent(i.LineContent)
|
||||
).ToList();
|
||||
|
||||
// Verify HS section headers are tracked in SkippedHSSectionHeaders
|
||||
// Verify HS section headers are NOT tracked in SkippedHSSectionHeaders when no school level is set
|
||||
var skippedHSHeaders = result.SkippedHSSectionHeaders;
|
||||
|
||||
// Verify continuation lines are skipped
|
||||
@@ -621,10 +622,10 @@ public class EventOccurrenceParser_Tests
|
||||
// Assertions
|
||||
Assert.That(totalOccurrences, Is.GreaterThan(0), "Should parse at least some occurrences");
|
||||
Assert.That(msEventCount, Is.GreaterThanOrEqualTo(14), "Should parse most MS occurrences (at least 14 out of 16)");
|
||||
// HS events should not create issues - they should be skipped gracefully
|
||||
Assert.That(hsIssues, Has.Count.EqualTo(0), "HS events should be skipped gracefully without creating issues");
|
||||
// HS section headers should be tracked
|
||||
Assert.That(skippedHSHeaders, Has.Count.GreaterThanOrEqualTo(2), "Should track at least 2 HS section headers (Coding - HS, CAD Architecture - HS, CAD Engineering - HS)");
|
||||
// When no school level is set, HS events should be processed (not skipped)
|
||||
// HS events may create issues if they don't match event definitions, which is expected
|
||||
// HS section headers should NOT be tracked when no school level is set
|
||||
Assert.That(skippedHSHeaders, Has.Count.EqualTo(0), "HS section headers should NOT be tracked when no school level is set");
|
||||
// Line 70 (starts with "*The") enters continuation mode and both line 70 and 71 should be skipped without issues
|
||||
Assert.That(continuationLineIssues, Has.Count.EqualTo(0),
|
||||
"Continuation lines starting with '*' and subsequent lines should be skipped without issues");
|
||||
@@ -677,41 +678,29 @@ public class EventOccurrenceParser_Tests
|
||||
var biotechnology = events.FirstOrDefault(e => e.Name == "Biotechnology");
|
||||
Assert.That(biotechnology, Is.Not.Null, "Biotechnology event should exist");
|
||||
|
||||
// MS occurrences should be parsed
|
||||
if (result.Occurrences.ContainsKey(biotechnology))
|
||||
{
|
||||
var msOccurrences = result.Occurrences[biotechnology];
|
||||
Assert.That(msOccurrences, Has.Count.EqualTo(2),
|
||||
"Should have 2 MS occurrences (Submit Entry and Judging)");
|
||||
|
||||
// Verify MS occurrences have correct names
|
||||
var msNames = msOccurrences.Select(o => o.Name).ToList();
|
||||
Assert.That(msNames, Does.Contain("Submit Entry"), "MS should have Submit Entry");
|
||||
Assert.That(msNames, Does.Contain("Judging"), "MS should have Judging");
|
||||
}
|
||||
// When no school level is set, all events (MS and HS) should be processed
|
||||
// HS section header should NOT be skipped (note: normalized to regular hyphen)
|
||||
Assert.That(result.SkippedHSSectionHeaders, Does.Not.Contain("Biotechnology Design - HS"),
|
||||
"HS section header should NOT be in SkippedHSSectionHeaders when no school level is set");
|
||||
|
||||
// HS section header should be skipped (note: normalized to regular hyphen)
|
||||
Assert.That(result.SkippedHSSectionHeaders, Does.Contain("Biotechnology Design - HS"),
|
||||
"HS section header should be in SkippedHSSectionHeaders");
|
||||
|
||||
// HS occurrences should NOT be associated with Biotechnology MS event
|
||||
// With no school level filtering, both MS and HS events are processed
|
||||
if (result.Occurrences.ContainsKey(biotechnology))
|
||||
{
|
||||
var allOccurrences = result.Occurrences[biotechnology];
|
||||
var hsOccurrenceNames = new[] { "Submit Entry", "Judging", "Pick-up" };
|
||||
var hsOccurrencesFound = allOccurrences.Where(o =>
|
||||
o.Name == "Submit Entry" && o.Date.Contains("April 3") ||
|
||||
o.Name == "Judging" && o.Date.Contains("April 3") ||
|
||||
o.Name == "Pick-up" && o.Date.Contains("April 4")).ToList();
|
||||
// With no school level set, we process all occurrences (both MS and HS)
|
||||
// Expected: 2 MS occurrences (Submit Entry, Judging) + 3 HS occurrences (Submit Entry, Judging, Pick-up) = 5 total
|
||||
Assert.That(allOccurrences, Has.Count.EqualTo(5),
|
||||
"Should have all 5 occurrences (2 MS + 3 HS) when no school level is set. " +
|
||||
$"Found {allOccurrences.Count} occurrences total.");
|
||||
|
||||
// The HS occurrences should not be in the MS event's occurrences
|
||||
// We expect only 2 MS occurrences, not 5 (2 MS + 3 HS)
|
||||
Assert.That(allOccurrences, Has.Count.LessThanOrEqualTo(2),
|
||||
"HS occurrences should not be associated with MS event. " +
|
||||
$"Found {allOccurrences.Count} occurrences, expected 2 MS only.");
|
||||
// Verify all expected occurrence names are present
|
||||
var occurrenceNames = allOccurrences.Select(o => o.Name).ToList();
|
||||
Assert.That(occurrenceNames, Does.Contain("Submit Entry"), "Should have Submit Entry occurrences");
|
||||
Assert.That(occurrenceNames, Does.Contain("Judging"), "Should have Judging occurrences");
|
||||
Assert.That(occurrenceNames, Does.Contain("Pick-up"), "Should have Pick-up occurrence");
|
||||
}
|
||||
|
||||
Assert.Pass("HS events correctly skipped and not associated with MS events");
|
||||
Assert.Pass("All events processed when no school level is set");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user