CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Silverlight Unit Test with time for the UI to update

453 Views
Copy Code Show/Hide Line Numbers
/// <summary>
/// Holds up the test execution for the given duration without blocking the UI thread.
/// </summary>
void UIPause(int sec)
{
    Storyboard PauseSB = new Storyboard() { Duration = new Duration(new TimeSpan(0, 0, sec)) };
    PauseSB.Completed += (sender, e) => { TestComplete(); };
    PauseSB.Begin();
}
 
[TestMethod]
[Asynchronous]
public void SampleTest()
{
    this.TestPanel.Children.Add(new Button());
 
     UIPause(50);
}
by Szili
  June 03, 2010 @ 8:51am
Tags:
Description:
When you run Presentation Tests for Silverlight controls the tests run so fast, that the ui doesn't have time to update.
This code gives you a method hold up the test for a given time (without blocking the ui thread) to actually see the test results on the Test Panel.
(I use the unit testing framework in Silverlight Toolkit.)

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate