当前位置: 首页>>代码示例>>C#>>正文


C# TimeSpan.FormatPretty方法代码示例

本文整理汇总了C#中System.TimeSpan.FormatPretty方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.FormatPretty方法的具体用法?C# TimeSpan.FormatPretty怎么用?C# TimeSpan.FormatPretty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeSpan的用法示例。


在下文中一共展示了TimeSpan.FormatPretty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_format_pretty

        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));
        }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:8,代码来源:TimeFormatterTests.cs

示例2: NotifyStepFinished_should_print_step_details

        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));
        }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:14,代码来源:ConsoleProgressNotifierTests.cs

示例3: NotifyScenarioFinished_should_print_scenario_result_with_provided_details

        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));
        }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:15,代码来源:ConsoleProgressNotifierTests.cs

示例4: GetDuration

 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();
 }
开发者ID:surgeforward,项目名称:LightBDD,代码行数:8,代码来源:HtmlResultTextWriter.cs


注:本文中的System.TimeSpan.FormatPretty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。