public static void EnqueueConditional(this EndToEndTestBase test, Func <bool> predicate) { while (!predicate()) { Sleep(DeltaMilliseconds); } }
/// <summary> /// Suspends the current thread until the asynchronous operation completes. /// </summary> /// <param name="test">The caller test</param> public static void WaitForTestToComplete(this EndToEndTestBase test) { while (!test.TestCompleted) { Sleep(DeltaMilliseconds); } }
/// <summary> /// Runs a client test with both Atom and Json OData formats. /// </summary> /// <typeparam name="TContext">The DataServiceContext type.</typeparam> /// <param name="testBase">The test class running the test.</param> /// <param name="createContext">A delegate to create the context.</param> /// <param name="test">The test action to execute.</param> public static void RunOnAtomAndJsonFormats <TContext>( this EndToEndTestBase testBase, Func <DataServiceContextWrapper <TContext> > createContext, Action <DataServiceContextWrapper <TContext> > test) where TContext : DataServiceContext { var jsonContext = createContext(); jsonContext.ContextLabel = "Json"; jsonContext.Format.UseJson(); testBase.InvokeDataDrivenTest(test, DataDrivenTest.CreateData(jsonContext)); }
/// <summary> /// Blocks the current thread until the current async result is completed. /// </summary> /// <param name="asyncResult">The async result to wait for completions</param> /// <param name="test">The current test.</param> /// <returns></returns> public static IAsyncResult EnqueueWait(this IAsyncResult asyncResult, EndToEndTestBase test) { // "test" parameter is never used, but is needed to maintain the same interface across platforms asyncResult.AsyncWaitHandle.WaitOne(); return(asyncResult); }
public static void EnqueueCallback(this EndToEndTestBase test, Action action) { action(); }
/// <summary> /// Mark the test as completed. Test should wait before exiting until this method is called. /// </summary> /// <param name="test">The asynchronous end-to-end test</param> public static void EnqueueTestComplete(this EndToEndTestBase test) { //If someday all the test cases are changed to the way that Linq_OrderByDescendingThenByDescendingTest is written, then this method should do nothing, just to be able to write test cases in the same way on all 4 platforms.This method is specific to SL. test.TestCompleted = true; }
/// <summary> /// Blocks the current thread until the current async result is completed. /// </summary> /// <param name="asyncResult">The async result to wait for completions</param> /// <param name="test">The current test</param> /// <returns></returns> public static IAsyncResult EnqueueWait(this IAsyncResult asyncResult, EndToEndTestBase test) { test.EnqueueConditional(() => asyncResult.IsCompleted); return(asyncResult); }
/// <summary> /// Shim to match desktop tests. Silverlight tests with the Asynchronous attribute wait unti they call EnqueueTestComplete /// </summary> /// <param name="test">The caller test</param> public static void WaitForTestToComplete(this EndToEndTestBase test) { }