public void Should_format_pretty(int days, int hours, int minutes, int seconds, int milliseconds, int microseconds, int nanoseconds, string expected) { var microTime = TimeSpan.FromTicks(((microseconds * TimeSpan.TicksPerMillisecond) / 1000)); var nanoTime = TimeSpan.FromTicks(((nanoseconds * TimeSpan.TicksPerMillisecond) / 1000000)); var timeSpan = new TimeSpan(days, hours, minutes, seconds, milliseconds).Add(microTime).Add(nanoTime); Assert.That(timeSpan.FormatPretty(), Is.EqualTo(expected)); }
public void NotifyStepFinished_should_print_step_details() { string stepName = "scenario name"; var stepNumber = 12; var totalStepCount = 19; var resultStatus = ResultStatus.Failed; var executionTime = new TimeSpan(0, 0, 0, 0, 127); string expectedText = string.Format(" STEP {0}/{1}: {2} ({3} after {4}){5}", stepNumber, totalStepCount, stepName, resultStatus, executionTime.FormatPretty(), Environment.NewLine); var result = Mocks.CreateStepResult(stepNumber, stepName, resultStatus, executionTime); _subject.NotifyStepFinished(result, totalStepCount); Assert.That(_console.GetCapturedText(), Is.EqualTo(expectedText)); }
public void NotifyScenarioFinished_should_print_scenario_result_with_provided_details(ResultStatus status) { var executionTime = new TimeSpan(0, 0, 27); string details = @"expected: A got: B"; string expectedText = string.Format(" SCENARIO RESULT: {0} after {1}{2} expected: A{2} got: B{2}", status, executionTime.FormatPretty(), Environment.NewLine); var result = MockRepository.GenerateMock<IScenarioResult>(); result.Stub(r => r.Status).Return(status); result.Stub(r => r.ExecutionTime).Return(executionTime); result.Stub(r => r.StatusDetails).Return(details); _subject.NotifyScenarioFinished(result); Assert.That(_console.GetCapturedText(), Is.EqualTo(expectedText)); }
private static IHtmlNode GetDuration(TimeSpan? executionTime) { return Html.Tag(HtmlTextWriterTag.Span) .Class("duration") .Content(executionTime != null ? string.Format("({0})", executionTime.FormatPretty()) : string.Empty) .SkipEmpty() .SpaceBefore(); }