示例#1
0
    public void ToXml()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        AssemblyResult assemblyResult = new AssemblyResult(filename, @"C:\Foo\Bar");

        XmlNode resultNode = assemblyResult.ToXml(parentNode);

        Assert.Equal("assembly", resultNode.Name);
        Assert.Equal(Path.GetFullPath(filename), resultNode.Attributes["name"].Value);
        Assert.Equal(@"C:\Foo\Bar", resultNode.Attributes["configFile"].Value);
        Assert.NotNull(resultNode.Attributes["run-date"]);
        Assert.NotNull(resultNode.Attributes["run-time"]);
        Assert.Equal("0.000", resultNode.Attributes["time"].Value);
        Assert.Equal("0", resultNode.Attributes["total"].Value);
        Assert.Equal("0", resultNode.Attributes["passed"].Value);
        Assert.Equal("0", resultNode.Attributes["failed"].Value);
        Assert.Equal("0", resultNode.Attributes["skipped"].Value);
        string expectedEnvironment = String.Format("{0}-bit .NET {1}", IntPtr.Size * 8, Environment.Version);
        Assert.Equal(expectedEnvironment, resultNode.Attributes["environment"].Value);
    }
示例#2
0
    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"));
    }