Now the LapTimes and Gaps are tested better and the Gaps detection has been improved to make it pass
This commit is contained in:
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TrackTrends
|
||||
{
|
||||
internal class DriverGapToLeaderWindow:Window
|
||||
public class DriverGapToLeaderWindow:Window
|
||||
{
|
||||
public DriverGapToLeaderWindow(Bitmap image, Rectangle bounds, bool generateEngine = true) : base(image, bounds,generateEngine)
|
||||
{
|
||||
|
||||
@@ -529,6 +529,10 @@ namespace TrackTrends
|
||||
// This should be the x:xx.xxx
|
||||
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());
|
||||
seconds = Convert.ToInt32(rawNumbers[1].ToString());
|
||||
miliseconds = Convert.ToInt32(rawNumbers[2].ToString());
|
||||
|
||||
@@ -31,7 +31,9 @@ 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++)
|
||||
{
|
||||
@@ -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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Reference in New Issue
Block a user