using Core.Parsers.EventOccurrence; using NUnit.Framework; namespace Tests.Parsers.EventOccurrence; [TestFixture] public class TimeLocationParser_Tests { [Test] public void Parse_TimeAndLocation_ExtractsBoth() { // Act TimeLocationParser.Parse("10:30 a.m. Room 101", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("10:30 a.m.")); Assert.That(location, Is.EqualTo("Room 101")); } [Test] public void Parse_TimeRangeAndLocation_ExtractsTimeRangeAndLocation() { // Act TimeLocationParser.Parse("10:00 a.m. - 12:00 p.m. Room 202", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("10:00 a.m. - 12:00 p.m.")); Assert.That(location, Is.EqualTo("Room 202")); } [Test] public void Parse_NOONAndLocation_ExtractsBoth() { // Act TimeLocationParser.Parse("NOON Hall C", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("NOON")); Assert.That(location, Is.EqualTo("Hall C")); } [Test] public void Parse_TimeOnly_NoLocation() { // Act TimeLocationParser.Parse("3:00 p.m.", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("3:00 p.m.")); Assert.That(location, Is.Empty); } [Test] public void Parse_AnyLocation_ExtractsLocationWithoutValidation() { // Act TimeLocationParser.Parse("10:00 a.m. Unknown Location", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("10:00 a.m.")); Assert.That(location, Is.EqualTo("Unknown Location")); } [Test] public void Parse_LocationWithTimeComponent_CleansTimeComponent() { // Act TimeLocationParser.Parse("10:00 a.m. - 12:15 p.m. Exhibit Hall C", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("10:00 a.m. - 12:15 p.m.")); Assert.That(location, Is.EqualTo("Exhibit Hall C")); } [Test] public void Parse_AnyLocation_ExtractsAsIs() { // Act TimeLocationParser.Parse("3:00 p.m. Room A", out string time, out string location); // Assert Assert.That(time, Is.EqualTo("3:00 p.m.")); Assert.That(location, Is.EqualTo("Room A")); } [Test] public void CleanLocationText_RemovesTimeAtStart() { // Act var result = TimeLocationParser.CleanLocationText("- 12:15 p.m. Exhibit Hall C"); // Assert Assert.That(result, Is.EqualTo("Exhibit Hall C")); } [Test] public void CleanLocationText_RemovesTimeWithoutDash() { // Act var result = TimeLocationParser.CleanLocationText("12:15 p.m. Exhibit Hall C"); // Assert Assert.That(result, Is.EqualTo("Exhibit Hall C")); } [Test] public void CleanLocationText_RemovesNOONAtStart() { // Act var result = TimeLocationParser.CleanLocationText("- NOON Exhibit Hall C"); // Assert Assert.That(result, Is.EqualTo("Exhibit Hall C")); } [Test] public void CleanLocationText_OnlyTime_ReturnsEmpty() { // Act var result = TimeLocationParser.CleanLocationText("12:15 p.m."); // Assert Assert.That(result, Is.Empty); } [Test] public void CleanLocationText_EmptyString_ReturnsEmpty() { // Act var result = TimeLocationParser.CleanLocationText(""); // Assert Assert.That(result, Is.Empty); } [Test] public void CleanLocationText_WhitespaceOnly_ReturnsEmpty() { // Act var result = TimeLocationParser.CleanLocationText(" "); // Assert Assert.That(result, Is.Empty); } [Test] public void CleanLocationText_NoTimeComponent_ReturnsOriginal() { // Act var result = TimeLocationParser.CleanLocationText("Exhibit Hall C"); // Assert Assert.That(result, Is.EqualTo("Exhibit Hall C")); } }