I am assuming that as the code is standard C#, I can just use nUnit, TestDriven.net etc.
Have I missed something?
What “traps” have other people hit trying to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are talking about testing C# code in a Silverlight-based project, then there are some steps that need to be taken in order to use frameworks such as nUnit. The C# code in a Silverlight project will compile against the Silverlight framework binaries, so the binaries for nUnit won’t work as-is since they are compiled against the standard .NET framework.
If you want to use nUnit, you can setup a regular C# class library and reference your Silverlight C# files into this project. You want to add them as a link, which is detailed here. From personal experience, this can get a little crazy because your file is linked in two places and the ability to link over the files are limited (if your Silverlight C# code references any Silverlight-specific binaries, you cannot perform this linking trick).
The other option is to use the Silverlight Unit Test Framework, the binaries for which can be found here. This works much like the Silverlight unit tester in the Silverlight Toolkit, except that it runs on the phone as a phone app.