Пример #1
0
        public void TestSleep()
        {
            var wakeUp = new WakeUpCommand();
            var e      = new ActiveObjectEngine();
            var c      = new SleepCommand(1000, e, wakeUp);

            e.AddCommand(c);
            var start = DateTime.Now;

            e.Run();
            var stop      = DateTime.Now;
            var sleepTime = (stop - start).TotalMilliseconds;

            Assert.IsTrue(sleepTime >= 1000, $"SleepTime {sleepTime} expected > 1000");
            Assert.IsTrue(sleepTime <= 1100, $"SleepTime {sleepTime} expected < 1100");
            Assert.IsTrue(wakeUp.Executed, "Command executed");
        }
Пример #2
0
 public SleepCommand(long milliseconds, ActiveObjectEngine e, Command wakeUpCommand)
 {
     sleepTime          = milliseconds;
     engine             = e;
     this.wakeUpCommand = wakeUpCommand;
 }