public void TimmerSettingRunRunStopStopAsync(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.StopTimerAsync(); System.Threading.Thread.Sleep(intervall * 2 + stopOffset); tmpTimer.StopTimerAsync(); _output.WriteLine(String.Join(", ", receivedEvents.ToArray())); int counter = (int)Math.Ceiling(((double)endTimer) / ((double)intervall)) + 1; Assert.Equal(stopCount + 1, receivedEvents.Count); Assert.Equal(endTimer - (intervall * stopCount), receivedEvents[receivedEvents.Count - 1]); }