public static TestCaseData ToTestCaseData <TResult>(EulerProblemInstance <TResult> instance) { var ret = new TestCaseData(instance); ret = new TestCaseData((Func <object>)(() => instance.Execute())); ret.TestName = $"Euler{instance.ProblemNumber:000}.{instance.Method}({instance.ParameterRepresentation})"; ret.ExpectedResult = instance.ExpectedResult; if (instance.IsCanonical) { ret.Properties.Add("Category", "Canonical"); } if (instance.IsFull) { ret.Properties.Add("Category", "Full"); } else { ret.Properties.Add("Category", "Mini"); } if (instance.IsSlow) { ret.Properties.Add("Category", "Slow"); ret.Explicit(); } return(ret); }
public static List <TestCaseData> RoomsFromJsonFile() { // read and parse file var filePath = "rooms.json"; var contents = File.ReadAllText(filePath); var rooms = JsonConvert.DeserializeObject <List <ExternalRoomData> >(contents); var testCases = new List <TestCaseData>(); //build up the test case data foreach (var test in rooms) { var testCase = new TestCaseData(test.RoomData) .SetName(test.TestName) .SetDescription(test.Description); test.Categories.ForEach(cat => testCase.SetCategory(cat)); if (test.IsExplicit) { testCase.Explicit(); } if (test.IsIgnored) { testCase.Ignore(test.IgnoreReason); } testCases.Add(testCase); } ; return(testCases); }