Пример #1
0
        public void TimmerSettingRunRunStop(int intervall, int endTimer, int stopCount, int stopOffset)
        {
            ServerTimer tmpTimer       = new ServerTimer();
            List <int>  receivedEvents = new List <int>();

            tmpTimer.ConnectionTimerEvent += delegate(int actTimming)
            {
                receivedEvents.Add(actTimming);
            };
            tmpTimer.StartTimer(endTimer, intervall);
            System.Threading.Thread.Sleep(intervall * stopCount + stopOffset);
            tmpTimer.StartTimer(endTimer, intervall);
            System.Threading.Thread.Sleep(intervall * stopCount + stopOffset);
            tmpTimer.StopTimer();
            System.Threading.Thread.Sleep(intervall * 2 + stopOffset);
            _output.WriteLine(String.Join(", ", receivedEvents.ToArray()));
            int counter = (int)Math.Ceiling(((double)endTimer) / ((double)intervall)) + 1;

            Assert.Equal(2 * (stopCount + 1), receivedEvents.Count);
            Assert.Equal(endTimer - (intervall * stopCount), receivedEvents[receivedEvents.Count - 1]);
        }