public TestResult ParseTest(string rawResult) { int statusEnd = rawResult.IndexOf(' '); int kindEnd = rawResult.IndexOf(' ', statusEnd + 1); int engineEnd = rawResult.IndexOf(' ', kindEnd + 1); int versionEnd = rawResult.IndexOf('/', engineEnd + 1); int locationEnd = rawResult.IndexOf('\n', versionEnd + 1); string status = rawResult.Substring(1, statusEnd - 2); string kind = rawResult.Substring(statusEnd + 1, kindEnd - statusEnd - 1); string engine = rawResult.Substring(kindEnd + 1, engineEnd - kindEnd - 1); string location = rawResult.Substring(versionEnd + 1, locationEnd - versionEnd - 1); TestResult testResult = new TestResult(); if (kind == ResultKind.Test) { IGallioResultParser helper = _parserFactory.GetParser(engine); testResult.Location = helper.ReformatLocation(location); switch (status.ToLower()) { case Status.Failed: case Status.Error: testResult.Status = TestStatus.Failed; testResult.Duration = string.Empty; string content = rawResult.Substring(locationEnd); testResult.Failure.Expected = helper.GetExpected(content); testResult.Failure.Actual = helper.GetActual(content); testResult.Failure.FailingStatement = DxCoreUtil.GetStatement(testResult.Location, helper.GetLineNumber(content)); testResult.Failure.ActualDiffersAt = helper.GetPosition(content, testResult.Failure.Expected, testResult.Failure.Actual); break; case Status.Passed: testResult.Status = TestStatus.Passed; testResult.Duration = string.Empty; break; default: case Status.Skipped: case Status.Ignored: testResult.Status = TestStatus.Skipped; break; } } return(testResult); }
/// <summary> /// Obtain a result parser for the framework in use. /// </summary> /// <param name="frameworkName"></param> /// <returns>A matching parser or the NullGallioParser if none exist in the collection</returns> public IGallioResultParser GetParser(string frameworkName) { IGallioResultParser parser = _parsers.Find(p => frameworkName.ToLower().StartsWith(p.Framwork.ToLower())); return(parser ?? new NullGallioParser()); }