C# Class Microsoft.Silverlight.Testing.WorkItemTest

Custom test class that provides the ability to perform semi-asynchronous test tasks on the main thread. Requires the custom unit test harness that manages and invokes test work items on the thread when needed. Tests using this functionality will not be compatible with the full desktop framework's Visual Studio Team Test environment.
Show file Open project: garyjohnson/wpnest Class Usage Examples

Public Methods

Method Description
EnqueueCallback ( ) : void

Adds a number of callback methods into the test task queue.

EnqueueCallback ( System.Action testCallbackDelegate ) : void

Add a Callback method into the test task queue. Similar to the PumpMessages(...) call, with the difference being that there is no longer a single requirement: you can enqueue several callback methods and other test tasks, all of which will execute before the test completes and/or the engine continues.

EnqueueConditional ( Func conditionalDelegate ) : void

Requires a bool returning delegate to be passed in. Instructs the test task queue to wait until the conditional call returns True to continue executing other test tasks and/or ending the test method.

EnqueueDelay ( System.TimeSpan delay ) : void

Delay a minimum amount of time before continuing. Similar to a sleep call that is not a blocking call.

EnqueueDelay ( double milliseconds ) : void

Delay a minimum amount of time before continuing. Similar to a sleep call that is not a blocking call.

EnqueueTestComplete ( ) : void

Enqueue a test task which calls the TestComplete method of SilverlightTest.

EnqueueWorkItem ( WorkItem testTaskObject ) : void

Add a task object to the test queue. For a test that is currently executing, all tasks contained within the queue are executed to completion (unless an Exception is thrown) -before- moving on to the next test. The test task queue replaces the PumpMessages(...) system that permitted a single callback. This enables specialized tasks, such as DOM bridge tasks, sleep tasks, and conditional continue tasks.

TestComplete ( ) : void

Signal that a test is complete when using Async testing. WARNING: If you use your own methods for completing, such as an HtmlTimer or other threading method, it is possible that this call will occur *AFTER* the test has timed out when using Timeouts. As such, be very careful as you could complete the call to the *next* test.

Private Methods

Method Description
CreateCallback ( System.Action testCallbackDelegate ) : WorkItem
CreateConditional ( Func conditionalDelegate ) : WorkItem
CreateDelay ( System.TimeSpan delay ) : WorkItem
Enqueue ( System.Action action ) : void
EnqueueSleep ( int sleepMillisecondsMinimum ) : void
Sleep ( int sleepMillisecondsMinimum, System.Action testCallback ) : void

Method Details

EnqueueCallback() public method

Adds a number of callback methods into the test task queue.
public EnqueueCallback ( ) : void
return void

EnqueueCallback() public method

Add a Callback method into the test task queue. Similar to the PumpMessages(...) call, with the difference being that there is no longer a single requirement: you can enqueue several callback methods and other test tasks, all of which will execute before the test completes and/or the engine continues.
public EnqueueCallback ( System.Action testCallbackDelegate ) : void
testCallbackDelegate System.Action Void-returning delegate, /// anonymous delegates work fine too.
return void

EnqueueConditional() public method

Requires a bool returning delegate to be passed in. Instructs the test task queue to wait until the conditional call returns True to continue executing other test tasks and/or ending the test method.
public EnqueueConditional ( Func conditionalDelegate ) : void
conditionalDelegate Func Conditional method or delegate. /// Test will halt until this condition returns True.
return void

EnqueueDelay() public method

Delay a minimum amount of time before continuing. Similar to a sleep call that is not a blocking call.
public EnqueueDelay ( System.TimeSpan delay ) : void
delay System.TimeSpan The minimum time span to wait before continuing.
return void

EnqueueDelay() public method

Delay a minimum amount of time before continuing. Similar to a sleep call that is not a blocking call.
public EnqueueDelay ( double milliseconds ) : void
milliseconds double The minimum number of milliseconds to wait /// until the delay is finished.
return void

EnqueueTestComplete() public method

Enqueue a test task which calls the TestComplete method of SilverlightTest.
public EnqueueTestComplete ( ) : void
return void

EnqueueWorkItem() public method

Add a task object to the test queue. For a test that is currently executing, all tasks contained within the queue are executed to completion (unless an Exception is thrown) -before- moving on to the next test. The test task queue replaces the PumpMessages(...) system that permitted a single callback. This enables specialized tasks, such as DOM bridge tasks, sleep tasks, and conditional continue tasks.
public EnqueueWorkItem ( WorkItem testTaskObject ) : void
testTaskObject WorkItem Asynchronous test task /// instance.
return void

TestComplete() public method

Signal that a test is complete when using Async testing. WARNING: If you use your own methods for completing, such as an HtmlTimer or other threading method, it is possible that this call will occur *AFTER* the test has timed out when using Timeouts. As such, be very careful as you could complete the call to the *next* test.
public TestComplete ( ) : void
return void