private static void test_durations() { var units = new string[] { "ms", "s", "m", "h", "d", "y" }; var p = new TimeSpanPrettyfier(units); AssertEquals("0 s", p.Prettify(new TimeSpan(0, 0, 0, 0))); AssertEquals("1 ms", p.Prettify(new TimeSpan(0, 0, 0, 0, 1))); AssertEquals("500 ms", p.Prettify(new TimeSpan(0, 0, 0, 0, 500))); AssertEquals("999 ms", p.Prettify(new TimeSpan(0, 0, 0, 0, 999))); AssertEquals("1 s", p.Prettify(new TimeSpan(0, 0, 0, 0, 1000))); AssertEquals("1 s", p.Prettify(new TimeSpan(0, 0, 0, 1))); AssertEquals("59 s", p.Prettify(new TimeSpan(0, 0, 0, 59))); AssertEquals("1 m", p.Prettify(new TimeSpan(0, 0, 0, 60))); AssertEquals("1.5 m", p.Prettify(new TimeSpan(0, 0, 0, 60 + 30))); AssertEquals("1.75 m", p.Prettify(new TimeSpan(0, 0, 0, 60 + 30 + 15))); AssertEquals("2 m", p.Prettify(new TimeSpan(0, 0, 0, 60 + 60))); AssertEquals("59 m", p.Prettify(new TimeSpan(0, 0, 0, 60 * 59))); AssertEquals("1 h", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60))); AssertEquals("23 h", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 23))); AssertEquals("1 d", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24))); AssertEquals("365 d", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * 365))); AssertEquals("1 y", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * 366))); AssertEquals("1.5 y", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * (365 + 182)))); }
private static void test_durations() { var units = new string[] { "ms", "s", "m", "h", "d" , "y"}; var p = new TimeSpanPrettyfier(units); AssertEquals("0 s", p.Prettify(new TimeSpan(0,0,0,0))); AssertEquals("1 ms", p.Prettify(new TimeSpan(0, 0, 0, 0,1))); AssertEquals("500 ms", p.Prettify(new TimeSpan(0, 0, 0, 0, 500))); AssertEquals("999 ms", p.Prettify(new TimeSpan(0, 0, 0, 0, 999))); AssertEquals("1 s", p.Prettify(new TimeSpan(0, 0, 0, 0, 1000))); AssertEquals("1 s", p.Prettify(new TimeSpan(0, 0, 0, 1))); AssertEquals("59 s", p.Prettify(new TimeSpan(0, 0, 0, 59))); AssertEquals("1 m", p.Prettify(new TimeSpan(0, 0, 0, 60))); AssertEquals("1.5 m", p.Prettify(new TimeSpan(0, 0, 0, 60+30))); AssertEquals("1.75 m", p.Prettify(new TimeSpan(0, 0, 0, 60 + 30 + 15))); AssertEquals("2 m", p.Prettify(new TimeSpan(0, 0, 0, 60 + 60 ))); AssertEquals("59 m", p.Prettify(new TimeSpan(0, 0, 0, 60 * 59 ))); AssertEquals("1 h", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60))); AssertEquals("23 h", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 23))); AssertEquals("1 d", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24))); AssertEquals("365 d", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * 365))); AssertEquals("1 y", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * 366))); AssertEquals("1.5 y", p.Prettify(new TimeSpan(0, 0, 0, 60 * 60 * 24 * (365 + 182)))); }