All methods done and unit tests all green.
This commit is contained in:
parent
90ff129e06
commit
170bb4bba0
1 changed files with 27 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue