Silverlight unit test

Source: Internet
Author: User

By default, vs2010 does not allow you to create a "Silverlight unit test" project, not vs2010, But Ms does not launch a template. It doesn't matter. Download one from the online template, for example:

After the installation is complete, you can create a sl unit test project, as shown in figure

One test:

First, create an SL class library project named sltools, which contains several lines of tests.Code:

 
Namespace sltools {public static class mathhelper {public static int add (int A, int B) {return a + B ;}}}
Create a sl unit test project named slunittest and create a test class. The Code is as follows:
Using system; using Microsoft. visual Studio. testtools. unittesting; using sltools; namespace slunittest {[testclass] public class mathhelperunittest {[testmethod] public void testaddmethod () {random RND = new random (); For (INT I = 0; I <10; I ++) {int A = RND. next (); int B = RND. next (); assert. areequal (mathhelper. add (A, B), (a + B ));}}}}
F5, run it: Note: unit testing is actually very useful for front-end web technologies such as SL. For example, the most commonly used WCF asynchronous calls cannot perform unit tests. for meaningful tests, they must be "automated tests based on the final UI page". Currently, such products are generally implemented by third parties, next Lecture.

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.