本文整理汇总了C#中System.TimeSpan.ToPrettyString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.ToPrettyString方法的具体用法?C# TimeSpan.ToPrettyString怎么用?C# TimeSpan.ToPrettyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.ToPrettyString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
public static void Log ( TimeSpan ts, string actionName, string context, string sDetail )
{
Messaging.Bus.Instance.Send (
new Messaging.StatusMessage (
Messaging.StatusMessage.Types.Debug,
context,
actionName + " took " + ts.ToPrettyString ( ),
sDetail ) );
}
示例2: BetweenIncluding
public static IMatcher<TimeSpan?> BetweenIncluding(TimeSpan expectFrom, TimeSpan expectTo)
{
return Matchers.Function((TimeSpan? actual) => actual.IsValidTimeSpan() && expectFrom.SafeCompareTo(actual) <= 0 && expectTo.SafeCompareTo(actual) >= 0, "a TimeSpan where " + expectFrom.ToPrettyString() + " <= value <= " + expectTo.ToPrettyString());
}
示例3: UtilityToPrettyTime
public void UtilityToPrettyTime()
{
TimeSpan timeSpan = new TimeSpan(3, 6, 27, 38);
Assert.AreEqual("3d 6h", timeSpan.ToPrettyString());
timeSpan = new TimeSpan(0, 4, 36, 59, 875);
Assert.AreEqual("4h 36m", timeSpan.ToPrettyString());
timeSpan = new TimeSpan(0, 0, 12, 17, 0);
Assert.AreEqual("12m 17s", timeSpan.ToPrettyString());
timeSpan = new TimeSpan(0, 0, 0, 2, 850);
Assert.AreEqual("2.8s", timeSpan.ToPrettyString());
timeSpan = new TimeSpan(0, 0, 0, 0, 300);
Assert.AreEqual("0.3s", timeSpan.ToPrettyString());
}
示例4: TimeSpan_Com_CentoECinquenta_Segundos_TEST
public void TimeSpan_Com_CentoECinquenta_Segundos_TEST()
{
TimeSpan t = new TimeSpan(0, 0, 150);
Assert.AreEqual("2 minutos", t.ToPrettyString());
}
示例5: Not
public static IMatcher<TimeSpan?> Not(TimeSpan expect)
{
return Matchers.Function((TimeSpan? actual) => actual.IsValidTimeSpan() && actual != expect, "a TimeSpan != " + expect.ToPrettyString());
}
示例6: LessThanOrEqualTo
public static IMatcher<TimeSpan?> LessThanOrEqualTo(TimeSpan expect)
{
return Matchers.Function((TimeSpan? actual) => actual.IsValidTimeSpan() && expect.SafeCompareTo(actual) >= 0, "a TimeSpan <= " + expect.ToPrettyString());
}
示例7: GreaterThan
public static IMatcher<TimeSpan?> GreaterThan(TimeSpan expect)
{
return Matchers.Function((TimeSpan? actual) => actual.IsValidTimeSpan() && expect.SafeCompareTo(actual) < 0, "a TimeSpan > " + expect.ToPrettyString());
}
示例8: EqualTo
public static IMatcher<TimeSpan?> EqualTo(TimeSpan expect)
{
return Matchers.Function((TimeSpan? actual) => actual == expect, "a TimeSpan == " + expect.ToPrettyString());
}
示例9: TimeSpan_Com_Trinta_Segundos_TEST
public void TimeSpan_Com_Trinta_Segundos_TEST()
{
TimeSpan t = new TimeSpan(0, 0, 30);
Assert.AreEqual("30 segundos", t.ToPrettyString());
}