private static int RunTest(TestOptions options)
{
var result = 1;
var solution = LoadSolution(options);
var tests = new List<Test>();
foreach (var project in solution.Projects)
{
if (project.TestFramework != null)
{
var buildTask = project.ToolChain.Build(console, project, "");
buildTask.Wait();
if (buildTask.Result)
{
var awaiter = project.TestFramework.EnumerateTestsAsync(project);
awaiter.Wait();
foreach (var test in awaiter.Result)
{
tests.Add(test);
}
}
else
{
result = 2;
}
}
}
foreach (var test in tests)
{
test.Run();
if (test.Pass)
{
Console.ForegroundColor = ConsoleColor.Green;
console.Write("\x1b[32;1m");
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
console.Write("\x1b[31;1m");
}
console.WriteLine(string.Format("Running Test: [{0}], [{1}]", test.Name, test.Pass ? "Passed" : "Failed"));
if (!test.Pass)
{
console.WriteLine(string.Format("Assertion = [{0}], File=[{1}], Line=[{2}]", test.Assertion, test.File, test.Line));
}
Console.ForegroundColor = ConsoleColor.White;
console.Write("\x1b[39; 49m");
if (!test.Pass)
{
result = 0;
break;
}
}
return result;
}