Names are now tested and all tests run
This commit is contained in:
@@ -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,29 +99,60 @@ 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");
|
||||
Bitmap falseExemple = (Bitmap)Image.FromFile(directory + "False.png");
|
||||
Bitmap trueExemple = (Bitmap)Image.FromFile(directory + "True.png");
|
||||
|
||||
DriverDrsWindow falseDRS = new DriverDrsWindow(falseExemple, new Rectangle(0, 0, falseExemple.Width, falseExemple.Height), true);
|
||||
DriverDrsWindow trueDRS = new DriverDrsWindow(trueExemple, new Rectangle(0, 0, trueExemple.Width, trueExemple.Height), true);
|
||||
DriverDrsWindow falseDRS = new DriverDrsWindow(falseExemple, new Rectangle(0, 0, falseExemple.Width, falseExemple.Height), true);
|
||||
DriverDrsWindow trueDRS = new DriverDrsWindow(trueExemple, new Rectangle(0, 0, trueExemple.Width, trueExemple.Height), true);
|
||||
|
||||
bool falseResult = (bool)falseDRS.DecodePng();
|
||||
bool trueResult = (bool)trueDRS.DecodePng();
|
||||
bool falseResult = (bool)falseDRS.DecodePng();
|
||||
bool trueResult = (bool)trueDRS.DecodePng();
|
||||
|
||||
Assert.IsFalse(falseResult);
|
||||
Assert.IsTrue(trueResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
Assert.IsFalse(falseResult);
|
||||
Assert.IsTrue(trueResult);
|
||||
}
|
||||
[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", "");
|
||||
|
||||
Reference in New Issue
Block a user