我正在尝试对一个Silverlight 3项目进行单元测试。我正在使用:
- Moq.Silverlight (3.0.308.2)
- NUnitSilverlight (http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/)
当我编写不使用Moq的测试时,它按预期工作。
当我在测试之外使用Moq时,Moq像应有的那样工作。(我模拟了一个接口并在按钮处理程序中进行验证以作为证明。)
但当我运行使用Moq的单元测试时,总是得到以下结果:
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.<>c__DisplayClassc`2.<Setup>b__b() in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Mock.cs: line 387
at Moq.PexProtector.Invoke<T>(Func`1 function) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\PexProtector.cs: line 17
at Moq.Mock.Setup<T1,TResult>(Mock mock, Expression`1 expression) in c:\Build\Moq Drop\moq\WorkingDirectory\trunk\Source\Mock.cs: line 371
at Moq.Mock`1.Setup<TResult>(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
如何解决这个问题?
我使用相同的方式重新构建了 SL 3 的两个程序集,但结果相同。
我能够在 Microsoft Silverlight 单元测试框架上运行测试。
http://code.msdn.microsoft.com/silverlightut/
这是一种基于浏览器的测试框架,似乎是单元测试 SL 的标准方式。但存在以下问题:
您必须一次运行所有测试
速度非常慢。
(与在 nunit 测试框架中运行的相同测试相比,速度慢大约5倍)
是否有人知道其他的 SL 测试框架或更好的方法来针对该框架运行测试?
当我尝试使用 TestDriven.Net 的 VS 插件时,会出现以下错误:
System.IO.FileNotFoundException: Could not load file or assembly 'System,...