public void SingleShotTimer_Elapsed_CanChangeToPeriodic() { bool autoReset = false; using (ActionThread thread = new ActionThread()) { thread.Start(); Timer timer = null; thread.DoSynchronously(() => { timer = new Timer(); timer.Elapsed += () => { timer.SetPeriodic(timer.Interval); autoReset = timer.AutoReset; timer.Cancel(); }; timer.AutoReset = false; timer.Interval = TimeSpan.FromMilliseconds(0); timer.Enabled = true; }); Thread.Sleep(10); thread.DoSynchronously(() => timer.Dispose()); } Assert.IsTrue(autoReset, "Single-shot Timer should be able to change to Periodic within Elapsed"); }
public void TimerType_AfterSetPeriodic_IsPeriodic() { bool autoReset = false; using (ActionThread thread = new ActionThread()) { thread.Start(); thread.DoSynchronously(() => { using (Timer timer = new Timer()) { timer.SetPeriodic(TimeSpan.FromMilliseconds(50)); autoReset = timer.AutoReset; } }); } Assert.IsTrue(autoReset, "Timer should be periodic"); }
public void Timer_AfterSetPeriodic_IsEnabled() { bool enabled = false; using (ActionThread thread = new ActionThread()) { thread.Start(); thread.DoSynchronously(() => { using (Timer timer = new Timer()) { timer.SetPeriodic(TimeSpan.FromMilliseconds(50)); enabled = timer.Enabled; } }); } Assert.IsTrue(enabled, "Timer.Enabled should be true"); }
public void Timer_AfterSetPeriodic_IsEnabled() { bool enabled = false; using (ActionThread thread = new ActionThread()) { thread.Start(); thread.DoSynchronously(() => { using (Timer timer = new Timer()) { timer.SetPeriodic(TimeSpan.FromMilliseconds(50)); enabled = timer.Enabled; } }); } Assert.IsTrue(enabled, "Timer.Enabled should be true"); }
public void TimerType_AfterSetPeriodic_IsPeriodic() { bool autoReset = false; using (ActionThread thread = new ActionThread()) { thread.Start(); thread.DoSynchronously(() => { using (Timer timer = new Timer()) { timer.SetPeriodic(TimeSpan.FromMilliseconds(50)); autoReset = timer.AutoReset; } }); } Assert.IsTrue(autoReset, "Timer should be periodic"); }
public void SingleShotTimer_Elapsed_CanChangeToPeriodic() { bool autoReset = false; using (ActionThread thread = new ActionThread()) { thread.Start(); Timer timer = null; thread.DoSynchronously(() => { timer = new Timer(); timer.Elapsed += () => { timer.SetPeriodic(timer.Interval); autoReset = timer.AutoReset; timer.Cancel(); }; timer.AutoReset = false; timer.Interval = TimeSpan.FromMilliseconds(0); timer.Enabled = true; }); Thread.Sleep(10); thread.DoSynchronously(() => timer.Dispose()); } Assert.IsTrue(autoReset, "Single-shot Timer should be able to change to Periodic within Elapsed"); }