using Core.Entities;
using Core.Parsers;

namespace Tests.Parsers;

public class EventOccurrenceParser_Tests
{
	
    [Test]
    public void ParseTest()
    {
		var events = TestEntityHandler.GetEvents();
		var parser = new EventOccurrenceParser(TestEntityHandler.GetEventOccurrenceFileInfo(), events);
		var dictionary = parser.Parse();
		Console.WriteLine($"Occurrence, Month, Date, Time, Location");
		foreach (var @event in events)
		{
			Console.WriteLine($"{@event.Name}");

			if (!dictionary.ContainsKey(@event))
			{
				Console.WriteLine("!!! eventDefinition not found " + @event.Name);
				continue;
			}
			var eventOccurrences = dictionary[@event];
		    foreach (var eo in eventOccurrences)
		    {
				Console.WriteLine($"\t{eo.StartTime.DayOfWeek} {eo.Time}, {eo.Name}, {eo.Location}");
			}
		}

		Console.WriteLine("General Schedule");
		foreach (var eo in dictionary[EventDefinition.GeneralSchedule].OrderBy(occurrence => occurrence.StartTime))
		{
			Console.WriteLine($"\t{eo.StartTime.DayOfWeek} {eo.Time}, {eo.Name}, {eo.Location}");
		}

		if (dictionary.ContainsKey(EventDefinition.VotingDelegates))
		foreach (var eo in dictionary[EventDefinition.VotingDelegates])
		{
			Console.WriteLine($"{eo.Name} {eo.StartTime}, {eo.Location}");
		}

		Assert.Pass();
    }
}