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
+1 -1
View File
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
namespace TrackTrends namespace TrackTrends
{ {
internal class DriverGapToLeaderWindow:Window public class DriverGapToLeaderWindow:Window
{ {
public DriverGapToLeaderWindow(Bitmap image, Rectangle bounds, bool generateEngine = true) : base(image, bounds,generateEngine) public DriverGapToLeaderWindow(Bitmap image, Rectangle bounds, bool generateEngine = true) : base(image, bounds,generateEngine)
{ {
+4
View File
@@ -529,6 +529,10 @@ namespace TrackTrends
// This should be the x:xx.xxx // This should be the x:xx.xxx
try try
{ {
//Gaps cant be more than 9 minuts so if there is more than 1 digit it means that the '+' has been understood as an other number
if (rawNumbers[0].Length > 1)
rawNumbers[0] = rawNumbers[0][rawNumbers[0].Length - 1].ToString();
minuts = Convert.ToInt32(rawNumbers[0].ToString()); minuts = Convert.ToInt32(rawNumbers[0].ToString());
seconds = Convert.ToInt32(rawNumbers[1].ToString()); seconds = Convert.ToInt32(rawNumbers[1].ToString());
miliseconds = Convert.ToInt32(rawNumbers[2].ToString()); miliseconds = Convert.ToInt32(rawNumbers[2].ToString());
+10 -7
View File
@@ -31,7 +31,9 @@ namespace TrackTrends.Tests
string[] checkDigits = fileName.Split('_'); string[] checkDigits = fileName.Split('_');
string[] digitsToCheck = time.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++)
{ {
@@ -51,12 +53,12 @@ namespace TrackTrends.Tests
foreach (string file in Directory.GetFiles(directory)) foreach (string file in Directory.GetFiles(directory))
{ {
Bitmap image = (Bitmap)Image.FromFile(file); 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[] paths = file.Split('/');
string fileName = paths[paths.Length - 1]; string fileName = paths[paths.Length - 1];
fileName = fileName.Replace(".png", ""); fileName = fileName.Replace(".png", "");
int timeMS = (int)lapTimeWindow.DecodePng(); int timeMS = (int)gapsWindow.DecodePng();
string time = Reader.ConvertMsToTime(timeMS); string time = Reader.ConvertMsToTime(timeMS);
string[] checkDigits = fileName.Split('_'); string[] checkDigits = fileName.Split('_');
@@ -68,13 +70,14 @@ namespace TrackTrends.Tests
} }
else 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++) for (int i = 0; i < checkDigits.Length; i++)
{ {
if (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
Console.Write("wut?"); Assert.AreEqual(Convert.ToInt32(checkDigits[i]), Convert.ToInt32(digitsToCheck[i]));
Assert.AreEqual(checkDigits[i], digitsToCheck[i]);
} }
} }
} }

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB