using Core.Entities;
using Core.Parsers;
using Core.Utility;

namespace Tests.Parsers;

public static class TestEntityHandler
{
	private const string ContentDirectory = @"Parsers\TestInput\";

	public static CompetitiveEvent[] GetCompetitiveEvents()
	{
		var fileInfo = FileUtility.GetContentFile(ContentDirectory, "2024-25 RMS TSA student & event - Event Definitions.csv");
		var eventRankingsParser = new EventDefinitionParser(fileInfo);
		return eventRankingsParser.Parse();
	}

	public static FileInfo GetEventOccurrenceFileInfo()
	{
		return FileUtility.GetContentFile(ContentDirectory, "2025 TSA Nationals Competition Event Times.txt");
	}

	public static Student[] GetStudents(IList<CompetitiveEvent> competitiveEvents)
	{
		//var studentEventRankingsCsv = "Student Event Rankings.csv";
		var studentEventRankingsCsv = "2024-25 RMS TSA student & event - Nationals Student Event Rankings.csv";

		var fileInfo = FileUtility.GetContentFile(ContentDirectory, studentEventRankingsCsv);
		var eventRankingsParser = new StudentParser(fileInfo);
		return eventRankingsParser.Parse(competitiveEvents);
	}


	public static Team[] GetTeams(IList<CompetitiveEvent> competitiveEvents, IList<Student> students)
	{
		//var studentEventRankingsCsv = "Student Event Rankings.csv";
		var studentEventRankingsCsv = "2024-25 RMS TSA student & event - Nationals Teams.csv";

		var fileInfo = FileUtility.GetContentFile(ContentDirectory, studentEventRankingsCsv);
		var eventRankingsParser = new TeamParser(fileInfo);
		var teams = eventRankingsParser.Parse(competitiveEvents, students);

		foreach (var student in students)
		{
			student.Teams = teams.Where(t => t.Students.Contains(student)).ToList();
		}
		return teams;
	}

	public static AssignmentAssumption[] GetEventAssumptions(IList<CompetitiveEvent> competitiveEvents, IList<Student> students)
	{
		var fileInfo = FileUtility.GetContentFile(ContentDirectory, "2024-25 RMS TSA student & event - assumptions.csv");
		var assumptionParser = new AssignmentAssumptionParser(fileInfo);
		return assumptionParser.Parse(competitiveEvents, students);
	}

}