Exemplo n.º 1
0
        public void IsDo_Test()
        {
            DateTime now = DateTime.Now;

            // 当前时间在区间段内
            HeartServerInfo hsi = new HeartServerInfo()
            {
                SpanInfo = new TimeConfig()
                {
                    StartTime = now.AddHours(-1).TimeOfDay,
                    EndTime   = now.AddHours(1).TimeOfDay
                }
            };
            RunningHeart r = new RunningHeart(hsi);

            Assert.AreEqual(true, r.IsDo());

            //时间相同
            hsi.SpanInfo.StartTime = now.AddHours(1).TimeOfDay;
            hsi.SpanInfo.EndTime   = now.AddHours(1).TimeOfDay;
            Assert.AreEqual(true, r.IsDo());

            // 当前时间在开始区间以外
            hsi.SpanInfo.StartTime = now.AddHours(1).TimeOfDay;
            hsi.SpanInfo.EndTime   = now.AddHours(2).TimeOfDay;
            Assert.AreEqual(false, r.IsDo());

            // 当前时间在结束时间以外
            hsi.SpanInfo.StartTime = now.AddHours(-1).TimeOfDay;
            hsi.SpanInfo.EndTime   = now.AddHours(-2).TimeOfDay;
            Assert.AreEqual(false, r.IsDo());
        }
Exemplo n.º 2
0
 public RunBase(RunningHeart rh)
 {
     runningHeart = rh;
 }
Exemplo n.º 3
0
 public RunningState(RunningHeart rh)
     : base(rh)
 {
 }
Exemplo n.º 4
0
 public PauseState(RunningHeart rh)
     : base(rh)
 {
 }
Exemplo n.º 5
0
 public ReadyState(RunningHeart rh)
     : base(rh)
 {
 }