public static VsTestResult ToVsTestResult(this TestResult testResult)
 {
     return(new VsTestResult(ToVsTestCase(testResult.TestCase))
     {
         Outcome = testResult.Outcome.ToVsTestOutcome(),
         ComputerName = testResult.ComputerName,
         DisplayName = testResult.DisplayName,
         Duration = testResult.Duration,
         ErrorMessage = testResult.ErrorMessage,
         ErrorStackTrace = testResult.ErrorStackTrace
     });
 }
 private void ReportTestResult(TestResult testResult)
 {
     VsTestResult result = testResult.ToVsTestResult();
     _throttle.Execute(delegate
     {
         // This is part of a workaround for a Visual Studio bug. See above.
         _frameworkHandle.RecordResult(result);
     });
     _frameworkHandle.RecordEnd(result.TestCase, result.Outcome);
 }
        private TestResult ParseTestResult(XmlNode testcaseNode)
        {
            string qualifiedName = GetQualifiedName(testcaseNode);

            TestCase testCase;
            if (!_testCasesMap.TryGetValue(qualifiedName, out testCase))
                return null;

            var testResult = new TestResult(testCase)
            {
                ComputerName = Environment.MachineName,
                DisplayName = testCase.DisplayName
            };

            string duration = testcaseNode.Attributes["time"].InnerText;
            testResult.Duration = ParseDuration(duration);

            string testCaseStatus = testcaseNode.Attributes["status"].InnerText;
            switch (testCaseStatus)
            {
                case "run":
                    XmlNodeList failureNodes = testcaseNode.SelectNodes("failure");
                    if (failureNodes.Count == 0)
                    {
                        testResult.Outcome = TestOutcome.Passed;
                    }
                    else
                    {
                        var parser = new ErrorMessageParser(failureNodes, _baseDir);
                        parser.Parse();
                        testResult.Outcome = TestOutcome.Failed;
                        testResult.ErrorMessage = parser.ErrorMessage;
                        testResult.ErrorStackTrace = parser.ErrorStackTrace;
                    }
                    break;
                case "notrun":
                    testResult.Outcome = TestOutcome.Skipped;
                    break;
                default:
                    string msg = "Unknown testcase status: " + testCaseStatus;
                    _testEnvironment.LogError(msg);
                    throw new Exception(msg);
            }

            return testResult;
        }
 private int GetDuration(TestResult testResult)
 {
     return (int)Math.Ceiling(testResult.Duration.TotalMilliseconds);
 }