Example #1
0
 public void SetUp()
 {
     wakeup = new WakeUpCommand();
     engine = new ActiveObjectEngine();
     sleep  = new SleepCommand(1000, engine, wakeup);
     engine.AddCommand(sleep);
 }
Example #2
0
        public void TestSleep()
        {
            WakeUpCommand      wakeUp       = new WakeUpCommand();
            ActiveObjectEngine objectEngine = new ActiveObjectEngine();
            SleepCommand       sleep        = new SleepCommand(1000, objectEngine, wakeUp);

            objectEngine.AddCommand(sleep);
            DateTime start = DateTime.Now;

            objectEngine.Run();
            DateTime stop      = DateTime.Now;
            double   sleepTime = (stop - start).TotalMilliseconds;

            Assert.IsTrue(sleepTime >= 1000, "SleepTime " + sleepTime + " exepcted > 1000");
            Assert.IsTrue(sleepTime <= 1100, "SleepTime " + sleepTime + " exepcted < 1100");
            Assert.IsTrue(wakeUp.executed, "Command Executed");
        }
Example #3
0
        public void TestSleep()
        {
            WakeUpCommand      wakeUp = new WakeUpCommand();
            ActiveObjectEngine e      = new ActiveObjectEngine();
            SleepCommand       c      = new SleepCommand(1000, e, wakeUp);

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

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

            Assert.IsTrue(sleepTime >= 1000,
                          $"SleepTime {sleepTime} expected > 1000");
            Assert.IsTrue(sleepTime <= 1000,
                          $"SleepTime {sleepTime} expected < 1000");
            Assert.IsTrue(wakeUp.executed, "Command executed");
        }