public void OnTestEvent(string report) { XmlNode xmlNode = XmlHelper.CreateXmlNode(report); switch (xmlNode.Name) { case "start-test": InvokeHandler(TestStarting, new TestNodeEventArgs(new TestNode(xmlNode))); break; case "start-suite": var testNode = new TestNode(xmlNode); CheckForProjectStart(testNode); InvokeHandler(SuiteStarting, new TestNodeEventArgs(testNode)); break; case "start-run": InitializeProjectDictionary(); InvokeHandler(RunStarting, new RunStartingEventArgs(xmlNode.GetAttribute("count", -1))); break; case "test-case": ResultNode resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; InvokeHandler(TestFinished, new TestResultEventArgs(resultNode)); break; case "test-suite": resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; CheckForProjectFinish(resultNode); InvokeHandler(SuiteFinished, new TestResultEventArgs(resultNode)); break; case "test-run": resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; InvokeHandler(RunFinished, new TestResultEventArgs(resultNode)); break; case "test-output": string testName = xmlNode.GetAttribute("testname"); string stream = xmlNode.GetAttribute("stream"); string text = xmlNode.InnerText; InvokeHandler(TestOutput, new TestOutputEventArgs(testName, stream, text)); break; case "unhandled-exception": string message = xmlNode.GetAttribute("message"); string stackTrace = xmlNode.GetAttribute("stacktrace"); InvokeHandler(UnhandledException, new UnhandledExceptionEventArgs(message, stackTrace)); break; } }
public TestResultEventArgs(ResultNode result) { if (result == null) { throw new ArgumentNullException("result"); } Result = result; }
public void CreateResultNode_CurrentCultureWithDifferentDelimiter_DoesNotThrowException() { TestDelegate newResultNode = () => { var resultNode = new ResultNode("<test-case duration='0.000'/>"); }; Assert.DoesNotThrow(newResultNode); }
public TestResultEventArgs(TestAction action, ResultNode result) : base(action) { if (result == null) { throw new ArgumentNullException("result"); } Result = result; }
private void CheckForProjectFinish(ResultNode resultNode) { if (_projectLookup.ContainsKey(resultNode.Id)) { var projectInfo = _projectLookup[resultNode.Id]; lock (projectInfo) { if (--projectInfo.AssembliesToRun == 0) { var projectResult = new ResultNode(projectInfo.ProjectNode.Xml); InvokeHandler(SuiteFinished, new TestResultEventArgs(projectResult)); } } } }
public static ResultSummary FromResultNode(ResultNode resultNode) { var result = resultNode.Xml; if (result.Name != "test-run") { throw new InvalidOperationException("Expected <test-run> as top-level element but was <" + result.Name + ">"); } var summary = new ResultSummary(); summary.OverallResult = resultNode.Outcome.Status.ToString(); summary.Duration = result.GetAttribute("duration", 0.0); summary.StartTime = result.GetAttribute("start-time", DateTime.MinValue); summary.EndTime = result.GetAttribute("end-time", DateTime.MaxValue); Summarize(result, summary); return(summary); }
public void OnTestEvent(string report) { XmlNode xmlNode = XmlHelper.CreateXmlNode(report); switch (xmlNode.Name) { case "start-test": InvokeHandler(TestStarting, new TestNodeEventArgs(new TestNode(xmlNode))); break; case "start-suite": InvokeHandler(SuiteStarting, new TestNodeEventArgs(new TestNode(xmlNode))); break; case "start-run": InvokeHandler(RunStarting, new RunStartingEventArgs(xmlNode.GetAttribute("count", -1))); break; case "test-case": ResultNode resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; InvokeHandler(TestFinished, new TestResultEventArgs(resultNode)); break; case "test-suite": resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; InvokeHandler(SuiteFinished, new TestResultEventArgs(resultNode)); break; case "test-run": resultNode = new ResultNode(xmlNode); _model.Results[resultNode.Id] = resultNode; InvokeHandler(RunFinished, new TestResultEventArgs(resultNode)); break; case "test-output": string testName = xmlNode.GetAttribute("testname"); string stream = xmlNode.GetAttribute("stream"); string text = xmlNode.InnerText; InvokeHandler(TestOutput, new TestOutputEventArgs(testName, stream, text)); break; } }
public void OnTestEvent(string report) { XmlNode xmlNode = XmlHelper.CreateXmlNode(report); switch (xmlNode.Name) { case "start-test": TestStarting?.Invoke(new TestNodeEventArgs(TestAction.TestStarting, new TestNode(xmlNode))); break; case "start-suite": SuiteStarting?.Invoke(new TestNodeEventArgs(TestAction.SuiteStarting, new TestNode(xmlNode))); break; case "start-run": RunStarting?.Invoke(new RunStartingEventArgs(xmlNode.GetAttribute("count", -1))); break; case "test-case": ResultNode result = new ResultNode(xmlNode); _model.Results[result.Id] = result; TestFinished?.Invoke(new TestResultEventArgs(TestAction.TestFinished, result)); break; case "test-suite": result = new ResultNode(xmlNode); _model.Results[result.Id] = result; SuiteFinished?.Invoke(new TestResultEventArgs(TestAction.SuiteFinished, result)); break; case "test-run": result = new ResultNode(xmlNode); _model.Results[result.Id] = result; RunFinished?.Invoke(new TestResultEventArgs(TestAction.RunFinished, result)); break; } }
private ResultSummary CreateResultSummary(string xml) { var resultNode = new ResultNode(xml); return(ResultSummaryCreator.FromResultNode(resultNode)); }