コード例 #1
0
ファイル: XmlFixtureReporter.cs プロジェクト: averrunci/Carna
    /// <summary>
    /// Reports the specified fixture running result to the specified XML element.
    /// </summary>
    /// <param name="result">The fixture running result.</param>
    /// <param name="element">The XML element to which the result is reported.</param>
    protected virtual void ReportFixture(FixtureResult result, XElement element)
    {
        var fixtureElement = new XElement("fixture",
                                          new XAttribute("type", result.FixtureDescriptor.FixtureAttributeType),
                                          new XAttribute("name", result.FixtureDescriptor.Name),
                                          new XAttribute("fullName", result.FixtureDescriptor.FullName),
                                          new XAttribute("description", result.FixtureDescriptor.Description),
                                          new XAttribute("tag", result.FixtureDescriptor.Tag ?? string.Empty),
                                          new XAttribute("benefit", result.FixtureDescriptor.Benefit ?? string.Empty),
                                          new XAttribute("role", result.FixtureDescriptor.Role ?? string.Empty),
                                          new XAttribute("feature", result.FixtureDescriptor.Feature ?? string.Empty),
                                          new XAttribute("background", result.FixtureDescriptor.Background ?? string.Empty),
                                          new XAttribute("status", result.Status),
                                          new XAttribute("startTime", result.StartTime.GetValueOrDefault()),
                                          new XAttribute("endTime", result.EndTime.GetValueOrDefault()),
                                          new XAttribute("duration", result.Duration.GetValueOrDefault().TotalSeconds),
                                          new XAttribute("formattedDescription", FixtureFormatter.FormatFixture(result.FixtureDescriptor))
                                          );

        if (result.Exception is not null)
        {
            fixtureElement.Add(new XElement("exception", result.Exception));
        }
        result.StepResults.ForEach(stepResult => ReportFixtureStep(stepResult, fixtureElement));
        result.Results.ForEach(subResult => ReportFixture(subResult, fixtureElement));

        element.Add(fixtureElement);
    }
コード例 #2
0
    /// <summary>
    /// Reports the title of the fixture with the specified fixture running result
    /// and level of the fixture running result.
    /// </summary>
    /// <param name="result">The fixture running result.</param>
    /// <param name="level">The level of the fixture running result.</param>
    /// <returns>The next level of the specified fixture running result.</returns>
    protected virtual int ReportFixtureTitle(FixtureResult result, int level)
    {
        var formattedDescription = FixtureFormatter.FormatFixture(result.FixtureDescriptor);

        if (result.FixtureDescriptor.FixtureAttributeType == typeof(AssemblyFixtureAttribute) ||
            result.FixtureDescriptor.FixtureAttributeType == typeof(NamespaceFixtureAttribute))
        {
            return(IsFullReport ? ReportFixtureTitle(formattedDescription, level, null) : level);
        }

        return(ReportFixtureTitle(formattedDescription, level, result.Status));
    }