當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。