Silverlight unit test framework

Source: Internet
Author: User

Microsoft launched a Silverlight unit test framework in. This framework was launched at the same time as Silverlight controls in mix 08, microsoft engineer Jeff Wilcox has been involved in maintaining the unit test framework.
Scott Gu's introduction to this framework
Video introduction provided by Jeff Wilcox
TheSource codeIt is already included in Silverlight controls. For more information, see the latest binary files and related tutorials and links on the msdn code homepage of this framework.

The following describes how to use the unit test framework.

First, download the latest single-test framework DLL from here.
Then we open vs2008 to create a Silverlight application to run the unit test. We name this project unittest.

Decompress the downloaded framework DLL to the project directory (I created a new ref directory), right-click references, and add the two extracted DLL files, Microsoft. silverlight. testing. DLL and Microsoft. visual Studio. qualitytools. unittesting. silverlight. DLL.

Because the framework can generate a test page, we put the page in the project. XAML and page. XAML. delete CS, and then open the app. XAML. CS, add to Microsoft. silverlight. testing Reference, and modify rootvisual to unittestsystem. createtestpage ();

View plaincopy to clipboardprint?
    1. # Using Microsoft. Silverlight. testing;
 
# Using Microsoft. Silverlight. testing;
View plaincopy to clipboardprint?
    1. Private VoidApplication_startup (ObjectSender, startupeventargs E)
    2. {
    3. This. Rootvisual = unittestsystem. createtestpage ();
    4. }
 
Private void application_startup (Object sender, startupeventargs e) {This. rootvisual = unittestsystem. createtestpage ();}

Then we add a class in the project, reference Microsoft. visualstudio. testtools. unittesting in the class, and add a testmethod,CodeAs follows:

View plaincopy to clipboardprint?
  1. UsingMicrosoft. visualstudio. testtools. unittesting;
  2. NamespaceUnittest
  3. {
  4. [Testclass]
  5. Public ClassTestgame
  6. {
  7. [Testmethod]
  8. Public VoidTestdispose ()
  9. {
  10. Assert. istrue (True);
  11. }
  12. }
  13. }
Using Microsoft. visualstudio. testtools. unittesting; namespace unittest {[testclass] public class testgame {[testmethod] public void testdispose () {assert. istrue (true );}}}

Press F5 to run the project and check the output result. Is it very convenient?

Of course, you can also use this framework to perform the Silverlight UI unit test. For details, refer to Jeff's article.Article.

Reprinted please indicate from the Chinese blog of et Wali Silverlight Technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.