Ejemplo n.º 1
0
        public void TimmerSettingNormal(int intervall, int endTimer)
        {
            ServerTimer tmpTimer = new ServerTimer();

            tmpTimer.StartTimer(endTimer, intervall);
            Assert.Equal(intervall, tmpTimer.TimerIntervall);
            Assert.Equal(endTimer, tmpTimer.Endtimer);
        }
Ejemplo n.º 2
0
        public void TimmerSettingChangeCombined(int intervall, int endTimer)
        {
            ServerTimer tmpTimer = new ServerTimer();

            tmpTimer.StartTimer(endTimer, intervall);
            Assert.Equal(1000, tmpTimer.TimerIntervall);
            Assert.Equal(1000, tmpTimer.Endtimer);
        }
Ejemplo n.º 3
0
        public void TimmerSettingRunRunStopAsync(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.StopTimerAsync();
            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]);
        }
Ejemplo n.º 4
0
        public void TimmerSettingRunNormal(int intervall, int endTimer)
        {
            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(endTimer + 2500);
            _output.WriteLine(String.Join(", ", receivedEvents.ToArray()));
            int counter = (int)Math.Ceiling(((double)endTimer) / ((double)intervall)) + 1;

            Assert.Equal(counter, receivedEvents.Count);
            Assert.Equal(0, receivedEvents[receivedEvents.Count - 1]);
            Assert.Equal(endTimer, receivedEvents[0]);
            if (intervall != endTimer)
            {
                Assert.Equal(endTimer - intervall, receivedEvents[1]);
            }
        }