コード例 #1
0
        public void Start_ShouldStartToCallOnTickOnEachTickable()
        {
            TickEngine   tickEngine = new TickEngine();
            TestTickable test       = new TestTickable();

            tickEngine.RegisterTickable(test);
            tickEngine.Start();
            Thread.Sleep(TickEngine.TICK_MILLISECONDS * 3);
            Assert.GreaterOrEqual(test.tickCalled, 2);
            tickEngine.Dispose();
        }
コード例 #2
0
        public void PauseAndResume_ShouldStopCallingOnTick()
        {
            TickEngine   tickEngine = new TickEngine();
            TestTickable test       = new TestTickable();

            tickEngine.RegisterTickable(test);

            tickEngine.Start();

            Thread.Sleep(TickEngine.TICK_MILLISECONDS * 3);
            tickEngine.Pause();
            Assert.GreaterOrEqual(test.tickCalled, 2);
            var currentTickNb = test.tickCalled;

            Thread.Sleep(TickEngine.TICK_MILLISECONDS * 3);
            Assert.AreEqual(test.tickCalled, currentTickNb);
            tickEngine.Resume();
            Thread.Sleep(TickEngine.TICK_MILLISECONDS * 3);

            Assert.GreaterOrEqual(test.tickCalled, 4);
            tickEngine.Dispose();
        }