Esempio n. 1
0
        public void GetElapsedTimesTest()
        {
            Assert.IsTrue(DotNetInterfaces.GetElapsedTimes(5).ToList().All(l => l < 100));

            TestElapsedTimes(10, 1000, 300);
            TestElapsedTimes(5, 2000, 500);
            TestElapsedTimes(20, 500, 250);
        }
Esempio n. 2
0
        private static void TestElapsedTimes(int count, int delay, int tolerance)
        {
            var result = DotNetInterfaces.GetElapsedTimes(count);
            int idx    = 0;

            foreach (var elapsed in result)
            {
                Assert.IsTrue(ApproxEqual(elapsed, idx++ == 0 ? 0 : delay, tolerance));
                Task.Delay(delay).Wait();
            }

            Assert.AreEqual(count + 1, idx);
        }