コード例 #1
0
 private static void AssertStepName(IStepResult step, string stepTypeName, string nameFormat, params StepParameterExpectation[] expectedParameters)
 {
     Assert.That(step.StepName, Is.Not.Null);
     Assert.That(step.StepName.NameFormat, Is.EqualTo(nameFormat));
     Assert.That(step.StepName.StepTypeName, Is.EqualTo(stepTypeName));
     AssertStepParameters(step.StepName.Parameters, expectedParameters);
 }
コード例 #2
0
        private static XElement ToXElement(IStepResult step)
        {
            var objects = new List <object>
            {
                new XAttribute("Status", step.Status.ToString()),
                new XAttribute("Number", step.Number),
                new XAttribute("Name", step.Name)
            };

            if (step.ExecutionStart != null)
            {
                objects.Add(new XAttribute("ExecutionStart", step.ExecutionStart));
            }
            if (step.ExecutionTime != null)
            {
                objects.Add(new XAttribute("ExecutionTime", step.ExecutionTime));
            }
            if (step.StatusDetails != null)
            {
                objects.Add(new XElement("StatusDetails", step.StatusDetails));
            }
            objects.Add(ToXElement(step.StepName));
            objects.Add(step.Comments.Select(c => new XElement("Comment", c)).Cast <object>().ToArray());
            return(new XElement("Step", objects));
        }
コード例 #3
0
 private static IHtmlNode GetStep(IStepResult step)
 {
     return(Html.Tag(HtmlTextWriterTag.Div).Class("step").Content(
                GetStatus(step.Status),
                Html.Text(string.Format("{0}. {1}", step.Number, step.StepName.Format(_stepNameDecorator))).Trim(),
                GetDuration(step.ExecutionTime)));
 }
コード例 #4
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);
            }
        }
コード例 #5
0
 /// <summary>
 /// Notifies that step has finished.
 /// </summary>
 /// <param name="step">Step result.</param>
 public void NotifyStepFinished(IStepResult step)
 {
     foreach (var notifier in _notifiers)
     {
         notifier.NotifyStepFinished(step);
     }
 }
コード例 #6
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));
        }
コード例 #7
0
 /// <summary>
 /// Notifies that step execution has been finished.
 /// </summary>
 /// <param name="stepResult">Step result.</param>
 /// <param name="totalStepCount">Total step count</param>
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
     foreach (var notifier in Notifiers)
     {
         notifier.NotifyStepFinished(stepResult, totalStepCount);
     }
 }
コード例 #8
0
 private XElement ToXElement(IStepResult step)
 {
     return(new XElement("Step",
                         new XAttribute("Status", step.Status.ToString()),
                         new XAttribute("Number", step.Number),
                         new XAttribute("Name", step.Name)));
 }
コード例 #9
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()));
 }
コード例 #10
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()));
 }
コード例 #11
0
 private static void CollectComments(IStepResult step, StringBuilder commentBuilder)
 {
     foreach (var comment in step.Comments)
     {
         commentBuilder.Append("\t\t\tStep ").Append(step.Info.GroupPrefix).Append(step.Info.Number)
         .Append(": ")
         .AppendLine(comment.Replace(Environment.NewLine, Environment.NewLine + "\t\t\t\t"));
     }
 }
コード例 #12
0
 private void WriteStep(HtmlTextWriter writer, IStepResult step)
 {
     WriteTag(writer, HtmlTextWriterTag.Div, "step", () =>
     {
         WriteStatus(writer, step.Status);
         WriteTag(writer, HtmlTextWriterTag.Span, "number", string.Format("{0}.", step.Number));
         writer.Write(step.Name);
     });
 }
コード例 #13
0
 private static void CollectComments(IStepResult step, StringBuilder commentBuilder)
 {
     foreach (var comment in step.Comments)
     {
         commentBuilder.Append("\t\t\tStep ")
             .Append(step.Number)
             .Append(": ")
             .AppendLine(comment.Replace(Environment.NewLine, Environment.NewLine + "\t\t\t\t"));
     }
 }
コード例 #14
0
 private static void FormatStep(StringBuilder builder, IStepResult step)
 {
     builder.Append("\t\tStep ")
     .Append(step.Number).Append(": ")
     .Append(step.Name).Append(" - ").Append(step.Status);
     if (step.ExecutionTime != null)
     {
         builder.Append(" (").Append(step.ExecutionTime.FormatPretty()).Append(")");
     }
     builder.AppendLine();
 }
コード例 #15
0
 private static void FormatStep(TextWriter writer, IStepResult step)
 {
     writer.Write("\t\tStep ");
     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();
 }
コード例 #16
0
        /// <summary>
        /// Notifies that step has finished.
        /// </summary>
        /// <param name="step">Step result.</param>
        public void NotifyStepFinished(IStepResult step)
        {
            var report = new List <string>
            {
                $"  STEP {step.Info.GroupPrefix}{step.Info.Number}/{step.Info.GroupPrefix}{step.Info.Total}: {step.Info.Name} ({step.Status} after {step.ExecutionTime.Duration.FormatPretty()})"
            };

            foreach (var parameter in step.Parameters)
            {
                if (parameter.Details is ITabularParameterDetails table)
                {
                    report.Add($"    {parameter.Name}:");
                    report.Add(new TextTableRenderer(table).Render("    "));
                }
            }
            _onNotify(string.Join(Environment.NewLine, report));
        }
コード例 #17
0
        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());
        }
コード例 #18
0
 public void NotifyStepFinished(IStepResult step)
 {
     _notifications.Add($"Step Finish: {FormatStep(step.Info)} | Status:{step.Status} | ExecutionTimePresent:{step.ExecutionTime != null} | Details:{step.StatusDetails}");
 }
コード例 #19
0
 private static IHtmlNode GetStep(IStepResult step)
 {
     return Html.Tag(HtmlTextWriterTag.Div).Class("step").Content(
         GetStatus(step.Status),
         Html.Text(string.Format("{0}. {1}", step.Number, step.StepName.Format(_stepNameDecorator))).Trim(),
         GetDuration(step.ExecutionTime));
 }
コード例 #20
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())));
 }
コード例 #21
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithExecutionTime(this IStepResult result, TimeSpan executionTime)
 {
     result.Stub(r => r.ExecutionTime).Return(executionTime);
     return(result);
 }
コード例 #22
0
 /// <summary>
 /// Notifies that step execution has been finished.
 /// </summary>
 /// <param name="stepResult">Step result.</param>
 /// <param name="totalStepCount">Total step count</param>
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
 }
コード例 #23
0
 public void NotifyStepFinished(IStepResult step)
 {
     _notifier.NotifyStepFinished(step);
 }
コード例 #24
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithTimes(this IStepResult result, DateTimeOffset executionStart, TimeSpan executionTime)
 {
     return(result.WithExecutionStart(executionStart)
            .WithExecutionTime(executionTime));
 }
コード例 #25
0
 /// <summary>
 /// Notifies that step execution has been finished.
 /// </summary>
 /// <param name="stepResult">Step result.</param>
 /// <param name="totalStepCount">Total step count</param>
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
     WriteLine("  STEP {0}/{1}: {2} ({3} after {4})", stepResult.Number, totalStepCount, stepResult.Name, stepResult.Status, stepResult.ExecutionTime.FormatPretty());
 }
コード例 #26
0
 /// <summary>
 /// Notifies that step has finished.
 /// </summary>
 /// <param name="step">Step result.</param>
 public void NotifyStepFinished(IStepResult step)
 {
     _onNotify($"  STEP {step.Info.GroupPrefix}{step.Info.Number}/{step.Info.GroupPrefix}{step.Info.Total}: {step.Info.Name} ({step.Status} after {step.ExecutionTime.Duration.FormatPretty()})");
 }
コード例 #27
0
 public void NotifyStepFinished(IStepResult step)
 {
 }
コード例 #28
0
 /// <summary>
 /// Notifies that step execution has been finished.
 /// </summary>
 /// <param name="stepResult">Step result.</param>
 /// <param name="totalStepCount">Total step count</param>
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
     WriteLine("  STEP {0}/{1}: {2} ({3} after {4})", stepResult.Number, totalStepCount, stepResult.Name, stepResult.Status, stepResult.ExecutionTime.FormatPretty());
 }
コード例 #29
0
 private static XElement ToXElement(IStepResult step)
 {
     var objects = new List<object>
     {
         new XAttribute("Status", step.Status.ToString()),
         new XAttribute("Number", step.Number),
         new XAttribute("Name", step.Name)
     };
     if (step.ExecutionStart != null)
         objects.Add(new XAttribute("ExecutionStart", step.ExecutionStart));
     if (step.ExecutionTime != null)
         objects.Add(new XAttribute("ExecutionTime", step.ExecutionTime));
     if (step.StatusDetails != null)
         objects.Add(new XElement("StatusDetails", step.StatusDetails));
     objects.Add(ToXElement(step.StepName));
     objects.Add(step.Comments.Select(c => new XElement("Comment", c)).Cast<object>().ToArray());
     return new XElement("Step", objects);
 }
コード例 #30
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithExecutionStart(this IStepResult result, DateTimeOffset executionStart)
 {
     result.Stub(r => r.ExecutionStart).Return(executionStart);
     return(result);
 }
コード例 #31
0
 /// <summary>
 /// Notifies that step execution has been finished.
 /// </summary>
 /// <param name="stepResult">Step result.</param>
 /// <param name="totalStepCount">Total step count</param>
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
     foreach (var notifier in Notifiers)
         notifier.NotifyStepFinished(stepResult, totalStepCount);
 }
コード例 #32
0
 private static void AssertStepName(IStepResult step, string stepTypeName, string nameFormat, params StepParameterExpectation[] expectedParameters)
 {
     Assert.That(step.StepName, Is.Not.Null);
     Assert.That(step.StepName.NameFormat, Is.EqualTo(nameFormat));
     Assert.That(step.StepName.StepTypeName, Is.EqualTo(stepTypeName));
     AssertStepParameters(step.StepName.Parameters, expectedParameters);
 }
コード例 #33
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithDetails(this IStepResult result, string statusDetails)
 {
     result.Stub(r => r.StatusDetails).Return(statusDetails);
     return(result);
 }
コード例 #34
0
ファイル: NoNotifier.cs プロジェクト: surgeforward/LightBDD
 public void NotifyStepFinished(IStepResult stepResult, int totalStepCount)
 {
 }
コード例 #35
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithStepNameDetails(this IStepResult result, string stepName, string nameFormat, string stepTypeName = null, params string[] parameters)
 {
     result.Stub(r => r.StepName).Return(CreateStepName(stepName, stepTypeName, nameFormat, parameters));
     result.Stub(r => r.Name).Return(stepName);
     return(result);
 }
コード例 #36
0
ファイル: Mocks.cs プロジェクト: vishalishere/LightBDD
 public static IStepResult WithComments(this IStepResult result, params string[] comments)
 {
     result.Stub(r => r.Comments).Return(comments);
     return(result);
 }
コード例 #37
0
 private static void FormatStep(StringBuilder builder, IStepResult step)
 {
     builder.Append("\t\tStep ")
         .Append(step.Number).Append(": ")
         .Append(step.Name).Append(" - ").Append(step.Status);
     if (step.ExecutionTime != null)
         builder.Append(" (").Append(step.ExecutionTime.FormatPretty()).Append(")");
     builder.AppendLine();
 }