コード例 #1
0
ファイル: TestSleepCommand.cs プロジェクト: pk2400178/CSharp
        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);
        }
コード例 #2
0
 public SleepCommand(long milliseconds, ActiveObjectEngine objectEngine, ICommand wakeUpcommand)
 {
     sleepTime          = milliseconds;
     engine             = objectEngine;
     this.wakeUpCommand = wakeUpCommand;
 }
コード例 #3
0
ファイル: SleepCommand.cs プロジェクト: pk2400178/CSharp
 public SleepCommand(long sleepTime, ActiveObjectEngine activeObjectEngine, Command wakeUp)
 {
     this.sleepTime          = sleepTime;
     this.activeObjectEngine = activeObjectEngine;
     this.wakeUp             = wakeUp;
 }