Exemple #1
0
        public void Start_OutputRemainingTime()
        {
            Console.SetOut(_stringWriter);
            int time = 2;

            _timer.Start(time);

            int sec = 1;
            int min = 0;

            Thread.Sleep(time * 1500);
            Assert.That(_stringWriter.ToString(), Contains.Substring($"Display shows: {min:D2}:{sec:D2}"));
        }
        public void Start_TimerTick_ShortEnough()
        {
            ManualResetEvent pause = new ManualResetEvent(false);

            uut.TimerTick += (sender, args) => pause.Set();
            uut.Start(2000);

            // wait for a tick, but no longer
            Assert.That(pause.WaitOne(1100));
        }