All methods done and unit tests all green.

This commit is contained in:
MarcUs7i 2024-09-12 19:22:02 +02:00
parent 90ff129e06
commit 170bb4bba0

View file

@ -26,8 +26,32 @@ public static class QualData
/// <returns>An array containing parsed match data records</returns>
public static Match[] ReadMatchesFromFile(string filePath)
{
// TODO
return [];
if (!File.Exists(filePath))
{
return Array.Empty<Match>();
}
string[] lines = File.ReadAllLines(filePath);
lines = lines.Skip(1).ToArray();
if (lines.Length == 0)
{
return Array.Empty<Match>();
}
//using lists to avoid resizing the array (Programmers are lazy)
var matches = new List<Match>();
foreach (var line in lines)
{
if (TryParseMatch(line, out Match? match))
{
matches.Add(match!);
}
else
{
return Array.Empty<Match>();
}
}
return matches.ToArray();
}
/// <summary>
@ -79,7 +103,7 @@ public static class QualData
{
foreach (var possibleValue in possibleValues)
{
if (possibleValue.ToLower() == value.ToLower())
if (string.Equals(possibleValue, value, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}