| Index: visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| diff --git a/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs b/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| index 27941426fb325c54a8d4f43f0ca1014d6319d639..bd9dbd3b939eec7cfdfd79deed6f7f273beb5931 100644
|
| --- a/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| +++ b/visual_studio/NativeClientVSAddIn/UnitTests/TestUtilities.cs
|
| @@ -36,6 +36,12 @@ namespace UnitTests
|
| public const string NotNaClProjectUniqueName = @"NotNaCl\NotNaCl.csproj";
|
|
|
| /// <summary>
|
| + /// A generic boolean statement to be used with RetryWithTimeout.
|
| + /// </summary>
|
| + /// <returns>True if the statement is true, false if false.</returns>
|
| + public delegate bool RetryStatement();
|
| +
|
| + /// <summary>
|
| /// This starts an instance of Visual Studio and get its DTE object.
|
| /// </summary>
|
| /// <returns>DTE of the started instance.</returns>
|
| @@ -155,6 +161,30 @@ namespace UnitTests
|
| }
|
|
|
| /// <summary>
|
| + /// Will retry the given statement up to maxRetry times while pausing between each try for
|
| + /// the given interval.
|
| + /// </summary>
|
| + /// <param name="test">Generic boolean statement.</param>
|
| + /// <param name="interval">Amount of time to wait between each retry.</param>
|
| + /// <param name="maxRetry">Maximum number of retries.</param>
|
| + /// <param name="message">Message to print on failure.</param>
|
| + public static void AssertTrueWithTimeout(
|
| + RetryStatement test, TimeSpan interval, int maxRetry, string message)
|
| + {
|
| + for (int tryCount = 0; tryCount <= maxRetry; tryCount++)
|
| + {
|
| + if (test.Invoke())
|
| + {
|
| + return;
|
| + }
|
| +
|
| + System.Threading.Thread.Sleep(interval);
|
| + }
|
| +
|
| + throw new Exception(string.Format("Statement timed out. {0}", message));
|
| + }
|
| +
|
| + /// <summary>
|
| /// This returns the text contained in the given output window pane.
|
| /// </summary>
|
| /// <param name="pane">Pane to get text from.</param>
|
|
|