Пример #1
0
        private static XElement ToXElement(IStepResult step, string elementName)
        {
            var objects = new List <object>
            {
                new XAttribute("Status", step.Status.ToString()),
                new XAttribute("Number", step.Info.Number),
                new XAttribute("Name", step.Info.Name)
            };

            if (step.ExecutionTime != null)
            {
                objects.Add(new XAttribute("ExecutionStart", step.ExecutionTime.Start));
                objects.Add(new XAttribute("ExecutionTime", step.ExecutionTime.Duration));
            }
            if (!string.IsNullOrEmpty(step.Info.GroupPrefix))
            {
                objects.Add(new XAttribute("GroupPrefix", step.Info.GroupPrefix));
            }
            if (step.StatusDetails != null)
            {
                objects.Add(new XElement("StatusDetails", step.StatusDetails));
            }
            objects.Add(ToXElement(step.Info.Name));
            objects.AddRange(step.Parameters.Select(ToXElement));
            objects.AddRange(step.Comments.Select(c => new XElement("Comment", c)));
            objects.AddRange(step.GetSubSteps().Select(s => ToXElement(s, "SubStep")));
            return(new XElement(elementName, objects));
        }
Пример #2
0
        private static void FormatStep(TextWriter writer, IStepResult step, StringBuilder commentBuilder, int indent = 0)
        {
            var stepIndent = new string('\t', indent + 2);

            writer.Write(stepIndent);
            writer.Write("Step ");
            writer.Write(step.Info.GroupPrefix);
            writer.Write(step.Info.Number);
            writer.Write(": ");
            writer.Write(step.Info.Name);
            writer.Write(" - ");
            writer.Write(step.Status);
            if (step.ExecutionTime != null)
            {
                writer.Write(" (");
                writer.Write(step.ExecutionTime.Duration.FormatPretty());
                writer.Write(")");
            }
            writer.WriteLine();
            foreach (var parameterResult in step.Parameters)
            {
                FormatParameter(writer, parameterResult, stepIndent);
            }
            CollectComments(step, commentBuilder);
            foreach (var subStep in step.GetSubSteps())
            {
                FormatStep(writer, subStep, commentBuilder, indent + 1);
            }
        }
Пример #3
0
 private static IHtmlNode GetStep(IStepResult step)
 {
     return(Html.Tag(Html5Tag.Div).Class("step").Content(
                GetStatus(step.Status),
                Html.Text(string.Format("{0}{1}. {2}", step.Info.GroupPrefix, step.Info.Number, step.Info.Name.Format(StepNameDecorator))).Trim(),
                GetDuration(step.ExecutionTime),
                Html.Tag(Html5Tag.Div).Class("sub-steps").Content(step.GetSubSteps().Select(GetStep)).SkipEmpty()));
 }
Пример #4
0
 private static IHtmlNode GetStep(IStepResult step)
 {
     return(Html.Tag(Html5Tag.Div).Class("step").Content(
                GetStatus(step.Status),
                Html.Text($"{WebUtility.HtmlEncode(step.Info.GroupPrefix)}{step.Info.Number}. {step.Info.Name.Format(StepNameDecorator)}").Trim(),
                GetDuration(step.ExecutionTime),
                Html.Tag(Html5Tag.Div).Class("step-parameters").Content(step.Parameters.Select(GetStepParameter)).SkipEmpty(),
                Html.Tag(Html5Tag.Div).Class("sub-steps").Content(step.GetSubSteps().Select(GetStep)).SkipEmpty()));
 }
        public string WriteSubSteps(IStepResult step, string prefixStep)
        {
            var subSteps = step.GetSubSteps();

            if ((subSteps?.Count() ?? 0) == 0)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder();



            foreach (var subStep in subSteps)
            {
                string comments = string.Join(";<br />", step.Comments);
                sb.AppendLine($"|{prefixStep}{subStep.Info.Number}|{subStep.Info.Name}|{subStep.Status}|{comments}|");
            }
            return(sb.ToString());
        }
Пример #6
0
 /// <summary>
 /// Returns enumeration over step-sub step hierarchy, including specified step.
 /// </summary>
 public static IEnumerable <IStepResult> GetAllSteps(this IStepResult step)
 {
     return(Enumerable.Repeat(step, 1).Concat(step.GetSubSteps().SelectMany(s => s.GetAllSteps())));
 }