public void then_fail_if_started_without_assigning_Tick() { ITimer timer = new RealtimeFixedIntervalTimer { Interval = 200 }; timer.Start(); }
public void then_fail_if_started_with_Interval_below_1() { ITimer timer = new RealtimeFixedIntervalTimer { Interval = 0 }; timer.Start(); Thread.Sleep(10); }
public void when_testing_MCD1() { RealtimeFixedIntervalTimer timer = TimerCreator.MCD(new List <int>() { 8, 4, 2, 12 }); timer.Interval.ShouldEqual(2 * 250); }
public void then_fail_if_Tick_changed_when_runnig() { RealtimeFixedIntervalTimer timer = new RealtimeFixedIntervalTimer { Interval = 100, Tick = new Action(() => { }) }; timer.Start(); timer.Tick = new Action(() => {}); }
public void then_can_start_timer() { ITimer timer = new RealtimeFixedIntervalTimer { Interval = 100 }; object lckTicks = new object(); int ticks = 0; timer.Tick = new Action(() => { lock (lckTicks) ticks++; }); timer.Start(); Thread.Sleep(1000); lock (lckTicks) { ticks.ShouldBeGreaterThan(8); Debug.WriteLine("Ticks: " + ticks); } }
public void then_timer_bypass_tick_if_already_running() { object lckTicks = new object(); int ticks = 0; ITimer timer = new RealtimeFixedIntervalTimer { Interval = 100 }; timer.Tick = new Action(() => { lock (lckTicks) ticks++; Thread.Sleep(500); }); timer.Start(); Thread.Sleep(1000); lock (lckTicks) { ticks.ShouldBeLessThanOrEqualTo(2); ticks.ShouldBeGreaterThanOrEqualTo(1); Debug.WriteLine("Ticks: " + ticks); } }
public void then_can_stop_timer() { object lckTicks = new object(); int ticks = 0; ITimer timer = new RealtimeFixedIntervalTimer { Interval = 100 }; timer.Tick = new Action(() => { lock (lckTicks) ticks++; }); timer.Start(); Thread.Sleep(100); timer.Stop(); int ticksWhenStop = 0; lock (lckTicks) ticksWhenStop = ticks; Thread.Sleep(1000); lock (lckTicks) ticks.ShouldEqual(ticksWhenStop); }