Now the LapTimes and Gaps are tested better and the Gaps detection has been improved to make it pass

This commit is contained in:
2023-06-01 11:21:29 +02:00
parent bf9ce57322
commit 9929a77b00
4 changed files with 16 additions and 9 deletions
+11 -8
View File
@@ -31,9 +31,11 @@ namespace TrackTrends.Tests
string[] checkDigits = fileName.Split('_');
string[] digitsToCheck = time.Split(':');
Assert.AreEqual(checkDigits.Length, digitsToCheck.Length);
//The ConvertMSToTime will always return three chars so we need to make the checkDigits be also three chars
while (checkDigits.Length != 3)
checkDigits = new[] { "0" }.Concat(checkDigits).ToArray();
for(int i = 0; i < checkDigits.Length; i++)
for (int i = 0; i < checkDigits.Length; i++)
{
Assert.AreEqual(checkDigits[i], digitsToCheck[i]);
}
@@ -51,12 +53,12 @@ namespace TrackTrends.Tests
foreach (string file in Directory.GetFiles(directory))
{
Bitmap image = (Bitmap)Image.FromFile(file);
DriverLapTimeWindow lapTimeWindow = new DriverLapTimeWindow(image, new Rectangle(0, 0, image.Width, image.Height), true);
DriverGapToLeaderWindow gapsWindow = new DriverGapToLeaderWindow(image, new Rectangle(0, 0, image.Width, image.Height), true);
string[] paths = file.Split('/');
string fileName = paths[paths.Length - 1];
fileName = fileName.Replace(".png", "");
int timeMS = (int)lapTimeWindow.DecodePng();
int timeMS = (int)gapsWindow.DecodePng();
string time = Reader.ConvertMsToTime(timeMS);
string[] checkDigits = fileName.Split('_');
@@ -68,13 +70,14 @@ namespace TrackTrends.Tests
}
else
{
Assert.AreEqual(checkDigits.Length, digitsToCheck.Length);
//The ConvertMSToTime will always return three chars so we need to make the checkDigits be also three chars
while(checkDigits.Length != 3)
checkDigits = new[] { "0" }.Concat(checkDigits).ToArray();
for (int i = 0; i < checkDigits.Length; i++)
{
if (checkDigits[i] != digitsToCheck[i])
Console.Write("wut?");
Assert.AreEqual(checkDigits[i], digitsToCheck[i]);
//We need to convert to int first because sometimes we have "08" and "8" and in string its not the same but in int it is
Assert.AreEqual(Convert.ToInt32(checkDigits[i]), Convert.ToInt32(digitsToCheck[i]));
}
}
}