2016-03-16 01:16:08 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Edge.A11y
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2016-03-16 21:28:34 +03:00
|
|
|
|
TestStrategy a11yStrategy = new EdgeStrategy();
|
2016-03-16 01:16:08 +03:00
|
|
|
|
|
2016-03-16 21:28:34 +03:00
|
|
|
|
var results = TestData.alltests.Value.Where(td => td._ControlType != null).ToList().ConvertAll(td => a11yStrategy.Execute(td));
|
2016-03-16 01:16:08 +03:00
|
|
|
|
|
|
|
|
|
var flatResults = results.Where(r => r.Any()).ToList().ConvertAll(r =>
|
|
|
|
|
{
|
|
|
|
|
var element = r.ElementAt(1);
|
|
|
|
|
element.Result = element.Result == ResultType.Fail && r.ElementAt(0).Result == ResultType.Pass ? ResultType.Half : element.Result;
|
|
|
|
|
element.Name = element.Name.Replace("-2", "");
|
|
|
|
|
return element;
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-01 01:12:22 +03:00
|
|
|
|
flatResults.OrderBy(r => r.Result).ToList().ForEach(r => Console.WriteLine(r));
|
2016-03-16 01:16:08 +03:00
|
|
|
|
|
|
|
|
|
var scores = flatResults.ConvertAll(r =>
|
|
|
|
|
{
|
|
|
|
|
switch (r.Result)
|
|
|
|
|
{
|
|
|
|
|
case ResultType.Fail:
|
|
|
|
|
return 0;
|
|
|
|
|
case ResultType.Half:
|
|
|
|
|
return .5;
|
|
|
|
|
case ResultType.Pass:
|
|
|
|
|
return 1;
|
|
|
|
|
default:
|
|
|
|
|
throw new InvalidDataException();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-25 03:26:17 +03:00
|
|
|
|
var score = scores.Average() * (scores.Count / 40.0);
|
2016-03-16 01:16:08 +03:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Edge Score: " + score * 100);
|
|
|
|
|
|
|
|
|
|
ResultsToCSV(flatResults);
|
|
|
|
|
|
2016-03-16 21:28:34 +03:00
|
|
|
|
a11yStrategy.Close();
|
2016-03-16 01:16:08 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ResultsToCSV(List<TestCaseResult> results)
|
|
|
|
|
{
|
|
|
|
|
var filePath = Path.Combine(DriverManager.ProjectRootFolder, "scores.csv");
|
|
|
|
|
var resultline = results.Select(r => r.Result.ToString()).Aggregate((s1, s2) => s1 + "," + s2);
|
|
|
|
|
if (!File.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
var headerLine = results.Select(r => r.Name).Aggregate((s1, s2) => s1 + "," + s2) + "\n";
|
|
|
|
|
File.WriteAllText(filePath, headerLine);
|
|
|
|
|
}
|
|
|
|
|
var writer = File.AppendText(filePath);
|
|
|
|
|
writer.WriteLine(resultline);
|
|
|
|
|
writer.Flush();
|
|
|
|
|
writer.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|