public async Task <T> CalculateRunTime <T>(Func <Task <T> > testToRun, bool printResult, [CallerMemberName] string testName = "")
        {
            TestTimer timer = new TestTimer()
            {
                PrintResult = printResult
            };
            T result = await testToRun();

            timer.EndAndPrint(testName);

            return(result);
        }
 public async Task ExecuteWithTimeout(TestTimer timer, int timeout, Func <Task <bool> > repeatedCode,
                                      TimeSpan?delay = null, [CallerMemberName] string testName = "")
 {
     while (true)
     {
         if (await repeatedCode())
         {
             timer.EndAndPrint(testName);
             break;
         }
         if (timer.TotalMilliSecondsUntilNow >= timeout)
         {
             Assert.True(false, $"{testName} timed out after {timeout} milliseconds");
             break;
         }
         if (delay.HasValue)
         {
             await Task.Delay(delay.Value);
         }
     }
 }