Пример #1
0
        public async Task StartNow_ExecutesEventImmediately()
        {
            var timer = new FfsTimer();

            timer.Elapsed += ActionToPerform;

            timer.StartNow(100000);
            timer.Stop();
            _numberOfExecutions.Should().Be(1);
        }
Пример #2
0
        public async Task StartNow_ExecutesFurtherEvents()
        {
            var timer = new FfsTimer();

            timer.Elapsed += ActionToPerform;

            timer.StartNow(1000);
            await Task.Delay(1000);

            timer.Stop();

            _numberOfExecutions.Should().Be(2);
        }
Пример #3
0
        public async Task Start_ExecutesScheduledEvent(int msBetweenExecutions, int numberOfExecutions)
        {
            var timer = new FfsTimer();

            timer.Elapsed += ActionToPerform;

            timer.Start(msBetweenExecutions);
            for (int i = 0; i < numberOfExecutions; i++)
            {
                await Task.Delay(msBetweenExecutions);
            }
            timer.Stop();

            _numberOfExecutions.Should().Be(numberOfExecutions);
        }