public void TestConvertDateTime() { var span = new TimeSpan(0, 12, 34, 56, 789); int time = 123456; int ms = 789; int hhmm_____ = 0; int ____ssf__ = 0; int _______ff = 0; var codec = new PbTickCodec(); codec.SetUpdateTime(span, out hhmm_____, out ____ssf__, out _______ff); Assert.AreEqual(1234, hhmm_____); Assert.AreEqual(567, ____ssf__); Assert.AreEqual(89, _______ff); codec.SetUpdateTime(time, ms, out hhmm_____, out ____ssf__, out _______ff); Assert.AreEqual(1234, hhmm_____); Assert.AreEqual(567, ____ssf__); Assert.AreEqual(89, _______ff); codec.GetUpdateTime(hhmm_____, ____ssf__, _______ff, out time, out ms); Assert.AreEqual(123456, time); Assert.AreEqual(789, ms); span = codec.GetUpdateTime(hhmm_____, ____ssf__, _______ff); Assert.AreEqual(0, span.Days); Assert.AreEqual(12, span.Hours); Assert.AreEqual(34, span.Minutes); Assert.AreEqual(56, span.Seconds); Assert.AreEqual(789, span.Milliseconds); var date1 = 20141104; var date2 = 20141105; var tick = new PbTick(); codec.SetActionDay(tick, new DateTime(2014, 11, 4)); codec.SetTradingDay(tick, new DateTime(2014, 11, 5)); Assert.AreEqual(date1, tick.ActionDay); Assert.AreEqual(date2, tick.TradingDay); Assert.AreEqual(new DateTime(2014, 11, 4), codec.GetDateTime(tick.ActionDay)); Assert.AreEqual(new DateTime(2014, 11, 5), codec.GetDateTime(tick.TradingDay)); }