Many of the operations in Silverlight are asynchronous and require unit tests to be asynchronous in many cases, but there are few documents that introduce asynchronous unit tests. Through the Microsoft.Silverlight.Testing in the Silverlight Toolkit and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight the analysis and attempts of these two files, finally found a way to do asynchronous unit testing, if necessary in Silverlight The asynchronous unit tests are used in the project in the following general steps:
Create a new Silverlight project, add a pair of Microsoft.Silverlight.Testing.dll, Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll a reference to a file, this does not have to do too much introduction.
Open the App.xaml.cs file, add a reference to the namespace Microsoft.Silverlight.Testing, locate the Application_Startup method, change the application's rootvisual to a test page, and then delete the Dynamic generated MainPage.xaml file, the modified Application_Startup method is as follows:
Create a new unit test class asynctest, let it inherit from the Microsoft.Silverlight.Testing.SilverlightTest base class, and then add the TestClass tag, as shown in the following illustration of the final file: