Names are now tested and all tests run

This commit is contained in:
2023-06-01 13:11:36 +02:00
parent a92b6bce8a
commit eb98466a98
+41 -10
View File
@@ -55,7 +55,7 @@ namespace TrackTrends.Tests
int foundPos = (int)posWindow.DecodePng();
Assert.AreEqual(Convert.ToInt32(fileName),foundPos);
Assert.AreEqual(Convert.ToInt32(fileName), foundPos);
}
}
[TestMethod()]
@@ -99,8 +99,6 @@ namespace TrackTrends.Tests
{
string directory = @"./../../TestImages/DRS/";
DirectoryInfo directoryInfo = new DirectoryInfo(directory);
if (Directory.Exists(directory))
{
Bitmap falseExemple = (Bitmap)Image.FromFile(directory + "False.png");
Bitmap trueExemple = (Bitmap)Image.FromFile(directory + "True.png");
@@ -113,15 +111,48 @@ namespace TrackTrends.Tests
Assert.IsFalse(falseResult);
Assert.IsTrue(trueResult);
}
else
{
Assert.Fail();
}
}
[TestMethod()]
public void DriverNameOCR_Test()
{
Assert.Fail();
string directory = @"./../../TestImages/Names/";
foreach (string file in Directory.GetFiles(directory))
{
Bitmap image = (Bitmap)Image.FromFile(file);
DriverNameWindow nameWindow = new DriverNameWindow(image, new Rectangle(0, 0, image.Width, image.Height), true);
string[] paths = file.Split('/');
string fileName = paths[paths.Length - 1];
fileName = fileName.Replace(".png", "");
List<string> driverList = new List<String>();
driverList.Add("Albon");
driverList.Add("Alonso");
driverList.Add("Bottas");
driverList.Add("De Vries");
driverList.Add("Gasly");
driverList.Add("Hamilton");
driverList.Add("Hulkenberg");
driverList.Add("Leclerc");
driverList.Add("Magnussen");
driverList.Add("Norris");
driverList.Add("Ocon");
driverList.Add("Perez");
driverList.Add("Piastri");
driverList.Add("Russel");
driverList.Add("Sainz");
driverList.Add("Sargeant");
driverList.Add("Stroll");
driverList.Add("Tsunoda");
driverList.Add("Verstappen");
driverList.Add("Zhou");
string foundName = (string)nameWindow.DecodePng(driverList);
//We only compare without the case because it does not really matter
//We remove the '_' from the file name for cases like "De Vries" wich obviously would be "De_Vries.png" as filename
fileName = fileName.Replace('_', ' ');
Assert.AreEqual(fileName.ToUpper(),foundName.ToUpper());
}
}
[TestMethod()]
public void SectorOCR_Test()
@@ -130,7 +161,7 @@ namespace TrackTrends.Tests
foreach (string file in Directory.GetFiles(directory))
{
Bitmap image = (Bitmap)Image.FromFile(file);
DriverSectorWindow sectorsWindow = new DriverSectorWindow(image, new Rectangle(0, 0, image.Width, image.Height), 1,true);
DriverSectorWindow sectorsWindow = new DriverSectorWindow(image, new Rectangle(0, 0, image.Width, image.Height), 1, true);
string[] paths = file.Split('/');
string fileName = paths[paths.Length - 1];
fileName = fileName.Replace(".png", "");