Now the positions are tested and pass

This commit is contained in:
2023-06-01 12:52:05 +02:00
parent 9929a77b00
commit 963383b1cc
+16 -4
View File
@@ -20,10 +20,10 @@ 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);
DriverLapTimeWindow lapTimeWindow = new DriverLapTimeWindow(image, new Rectangle(0, 0, image.Width, image.Height), true);
string[] paths = file.Split('/');
string fileName = paths[paths.Length - 1];
fileName = fileName.Replace(".png","");
fileName = fileName.Replace(".png", "");
int timeMS = (int)lapTimeWindow.DecodePng();
string time = Reader.ConvertMsToTime(timeMS);
@@ -44,7 +44,19 @@ namespace TrackTrends.Tests
[TestMethod()]
public void PositionOCR_Test()
{
Assert.Fail();
string directory = @"./../../TestImages/Positions/";
foreach (string file in Directory.GetFiles(directory))
{
Bitmap image = (Bitmap)Image.FromFile(file);
DriverPositionWindow posWindow = new DriverPositionWindow(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 foundPos = (int)posWindow.DecodePng();
Assert.AreEqual(Convert.ToInt32(fileName),foundPos);
}
}
[TestMethod()]
public void GapToLeaderOCR_Test()
@@ -71,7 +83,7 @@ namespace TrackTrends.Tests
else
{
//The ConvertMSToTime will always return three chars so we need to make the checkDigits be also three chars
while(checkDigits.Length != 3)
while (checkDigits.Length != 3)
checkDigits = new[] { "0" }.Concat(checkDigits).ToArray();
for (int i = 0; i < checkDigits.Length; i++)