Note that there are some explanatory texts on larger screens.

plurals
  1. POUnit testing with Moq, Silverlight and NUnit
    text
    copied!<p>I am attempting to unit test a Silverlight 3 project. I am using:</p> <ul> <li>Moq.Silverlight (3.0.308.2) </li> <li>NUnitSilverlight (<a href="http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/" rel="noreferrer">http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/</a>)</li> </ul> <p>When I write a test that does not use <a href="http://code.google.com/p/moq/" rel="noreferrer">Moq</a>, it works as it should.</p> <p>When I use Moq outside of a test, Moq works as it should. (I mocked a interface and did a verify in a button handler as a proof.)</p> <p>But when I run a unit test that uses Moq, I always get this:</p> <pre><code>System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified. at Moq.ExpressionExtensions.ToStringFixVisitor..ctor(Expression expression) at Moq.Interceptor.AddCall(IProxyCall call, SetupKind kind) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Interceptor.cs: line 104 at Moq.Mock.&lt;&gt;c__DisplayClassc`2.&lt;Setup&gt;b__b() in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Mock.cs: line 387 at Moq.PexProtector.Invoke&lt;T&gt;(Func`1 function) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\PexProtector.cs: line 17 at Moq.Mock.Setup&lt;T1,TResult&gt;(Mock mock, Expression`1 expression) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Mock.cs: line 371 at Moq.Mock`1.Setup&lt;TResult&gt;(Expression`1 expression) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Mock.Generic.cs: line 194 at SilverlightMoq.Test1.TestFirst() in Test1.cs: line 23 </code></pre> <p>How can it be fixed?</p> <hr> <p>I rebuilt both assemblies for SL 3 with the same results. </p> <p>I was able to get the test running on the Microsoft Silverlight Unit Test Framework.</p> <p><a href="http://code.msdn.microsoft.com/silverlightut/" rel="noreferrer">http://code.msdn.microsoft.com/silverlightut/</a></p> <p>This is the in-browser test framework that seems to be the standard way to unit test SL. The problems are:</p> <ol> <li>you must run all your tests at once</li> <li><p>it is brutally slow.</p> <p>(~5 times slower than the same tests running in the nunit test framework)</p></li> </ol> <p>Does anyone know of any other SL test frameworks or a better way to run the tests against this framework?</p> <p>When I attempt to use TestDriven.Net 's vs plugin I get an error:</p> <p>System.IO.FileNotFoundException: Could not load file or assembly 'System,...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload