コード例 #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));
    }
コード例 #3
0
    /// <summary>
    /// Reports the fixture step running result that is contained by the specified fixture running result
    /// and the 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>
    protected virtual void ReportFixtureStep(FixtureResult result, int level)
    {
        if (!StepVisible)
        {
            return;
        }

        var indent = Indent(level);

        result.StepResults.ForEach(stepResult =>
        {
            ReportValue(JoinFormattedLines(FixtureFormatter.FormatFixtureStep(stepResult.Step), indent), stepResult.Status);
            ReportStatus(stepResult.Status, true);
        });
    }
コード例 #4
0
ファイル: XmlFixtureReporter.cs プロジェクト: averrunci/Carna
    /// <summary>
    /// Reports the specified fixture step running result to the specified XML element.
    /// </summary>
    /// <param name="result">The fixture step running result.</param>
    /// <param name="element">The XML element to which the result is reported.</param>
    protected virtual void ReportFixtureStep(FixtureStepResult result, XElement element)
    {
        var stepElement = new XElement("step",
                                       new XAttribute("type", result.Step.GetType()),
                                       new XAttribute("description", result.Step.Description),
                                       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.FormatFixtureStep(result.Step))
                                       );

        if (result.Exception is not null)
        {
            stepElement.Add(new XElement("exception", result.Exception));
        }

        element.Add(stepElement);
    }
コード例 #5
0
 public FixtureFormatterSpec_FormatFixtureStep()
 {
     Formatter   = new FixtureFormatter();
     Description = "Description";
 }
コード例 #6
0
 public FixtureFormatterSpec_FormatFixture()
 {
     Formatter   = new FixtureFormatter();
     Name        = "Test";
     Description = "Description";
 }