public void Testsleep() { WakeUpCommand wakeUp = new WakeUpCommand(); ActiveObjectEngine activeObjectEngine = new ActiveObjectEngine(); SleepCommand sleepCommand = new SleepCommand(1000, activeObjectEngine, wakeUp); activeObjectEngine.AddCommand(sleepCommand); DateTime start = DateTime.Now; activeObjectEngine.Run(); DateTime end = DateTime.Now; double sleepTime = (end - start).TotalMilliseconds; Assert.True(sleepTime >= 1000, $"sleep time {sleepTime} expected > 1000"); //Assert.True(sleepTime <= 1000, $"sleep time {sleepTime} expected < 1000"); Assert.True(wakeUp.excuted); }
public SleepCommand(long milliseconds, ActiveObjectEngine objectEngine, ICommand wakeUpcommand) { sleepTime = milliseconds; engine = objectEngine; this.wakeUpCommand = wakeUpCommand; }
public SleepCommand(long sleepTime, ActiveObjectEngine activeObjectEngine, Command wakeUp) { this.sleepTime = sleepTime; this.activeObjectEngine = activeObjectEngine; this.wakeUp = wakeUp; }