public void ToXml() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<foo/>"); XmlNode parentNode = doc.ChildNodes[0]; MethodInfo method = typeof(StubClass).GetMethod("StubMethod"); SkipResult skipResult = new SkipResult(Reflector.Wrap(method), null, "the reason"); XmlNode resultNode = skipResult.ToXml(parentNode); Assert.Equal("Skip", resultNode.Attributes["result"].Value); Assert.Null(resultNode.Attributes["success"]); Assert.Null(resultNode.Attributes["time"]); Assert.Null(resultNode.SelectSingleNode("failure")); Assert.Equal("the reason", resultNode.SelectSingleNode("reason/message").InnerText); }
public void ToXml_WithChildren() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<foo/>"); XmlNode parentNode = doc.ChildNodes[0]; PassedResult passedResult = new PassedResult("foo", "bar", null, null); passedResult.ExecutionTime = 1.1; FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack"); failedResult.ExecutionTime = 2.2; SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason"); ClassResult classResult = new ClassResult(typeof(object)); classResult.Add(passedResult); classResult.Add(failedResult); classResult.Add(skipResult); AssemblyResult assemblyResult = new AssemblyResult(filename); assemblyResult.Add(classResult); XmlNode resultNode = assemblyResult.ToXml(parentNode); Assert.Equal("3.300", resultNode.Attributes["time"].Value); Assert.Equal("3", resultNode.Attributes["total"].Value); Assert.Equal("1", resultNode.Attributes["passed"].Value); Assert.Equal("1", resultNode.Attributes["failed"].Value); Assert.Equal("1", resultNode.Attributes["skipped"].Value); Assert.Single(resultNode.SelectNodes("class")); }
public void ToXmlTwiceDoesNotDoubleCounts() { XmlDocument doc = new XmlDocument(); doc.LoadXml("<foo/>"); XmlNode parentNode = doc.ChildNodes[0]; ClassResult classResult = new ClassResult(typeof(object)); PassedResult passedResult = new PassedResult("foo", "bar", null, null); passedResult.ExecutionTime = 1.1; FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack"); failedResult.ExecutionTime = 2.2; SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason"); classResult.Add(passedResult); classResult.Add(failedResult); classResult.Add(skipResult); XmlNode resultNode1 = classResult.ToXml(parentNode); XmlNode resultNode2 = classResult.ToXml(parentNode); Assert.Equal(resultNode1.Attributes["time"].Value, resultNode2.Attributes["time"].Value); Assert.Equal(resultNode1.Attributes["total"].Value, resultNode2.Attributes["total"].Value); Assert.Equal(resultNode1.Attributes["passed"].Value, resultNode2.Attributes["passed"].Value); Assert.Equal(resultNode1.Attributes["failed"].Value, resultNode2.Attributes["failed"].Value); Assert.Equal(resultNode1.Attributes["skipped"].Value, resultNode2.Attributes["skipped"].Value); Assert.Equal(resultNode1.SelectNodes("test").Count, resultNode2.SelectNodes("test").Count); }