views:

239

answers:

3

I had a unit test project for my windows phone 7 app ViewModels using the April Tools Refresh and everything worked fine. I just updated to the beta tools and now I can't get the test project to add a reference to nunit. The error I receive is

"Reference can not be added because it was not built using the Windows Phone runtime. Windows Phone projects will work only with Windows Phone assemblies."

What type of project should/can I create for a test project?

I also use ReSharper to run my tests. I was able to get it to build by copying the project from my old solution and adding it to the new beta solution. But when I run the tests I get the following error from ReSharper:

Unit Test Runner failed to load test assembly: JetBrains.ReSharper.TaskRunnerFramework.TaskException: Could not load file or assembly 'System.Device, Version=2.0.5.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e' or one of its dependencies. The system cannot find the file specified.

+1  A: 

You need to use the Silverlight Unit Test framework, specifically built for Windows Phone 7. Your test project will actually be a Windows Phone 7 client project, and your tests will run in the emulator.

There's a good explanation by a friend of mine here, with sample code and links to the test framework downloads.

And no, I don't think you can use the ReSharper test runner to run individual tests.

Ben Gracewood
Thanks but I had found the Silverlight Unit Test Framework and was trying to avoid running my tests through silverlight.
chief7
+1  A: 

so can i get the vote up for it seeing as a wrote it? :) only kidding!

Keith Patton
Keiths comments:Sign In to Votehttp://www.markerstudio.com/technical/2010/07/mvvm-light-and-unit-testing-example/ I've written an in depth article covering getting started with unit testing using the sikverlight nut testing framework and mvvm light if that helps?
chief7
+1  A: 

I found Jamie Cansdale's Silverlight NUnit Project Templates which did the trick.

Basically you use these templates, update the Silverlight version to 4 and update the ProjectTypeGuids to match the WP7 app project file.

Check out all the details on my blog: http://dotnetcatch.wordpress.com/2010/07/26/unit-testing-nunit-a-wp7-project/

chief7