Silverlight单元测试。运行测试时出错

Silverlight单元测试。运行测试时出错,silverlight,unit-testing,nunit,typemock,Silverlight,Unit Testing,Nunit,Typemock,我正在使用VS2010。Silverlight 4、NUnit 2.5.5和TypeMock TypemockIsolatorSetup6.0.3.619.msi 在实现MVVM的测试项目中,PeopleViewModel是我想要测试的ViewModel 请告知您是否使用其他产品进行MVVM Silverlight的单元测试。或者请帮助赢得这场比赛。短暂性脑缺血发作 这是测试代码: [Test] [SilverlightUnitTest] public void SomeTestAgainst

我正在使用VS2010。Silverlight 4、NUnit 2.5.5和TypeMock TypemockIsolatorSetup6.0.3.619.msi

在实现MVVM的测试项目中,PeopleViewModel是我想要测试的ViewModel

请告知您是否使用其他产品进行MVVM Silverlight的单元测试。或者请帮助赢得这场比赛。短暂性脑缺血发作

这是测试代码:

[Test]
[SilverlightUnitTest] 
public void SomeTestAgainstSilverlight()
{
    PeopleViewModel o = new PeopleViewModel();
    var res = o.People;

    Assert.AreEqual(15, res.Count());
}
在ReSharper中运行测试时,出现以下错误:

TestA.SomeTestAgainstSilverlight : Failed******************************************
*Loading Silverlight Isolation Aspects...*
******************************************

 TEST RESULTS:
---------------------------------------------

    System.MissingMethodException : Method not found: 'hv TypeMock.ArrangeActAssert.Isolate.a(System.Delegate)'.
    at a4.a(ref Delegate A_0)
    at a4.a(Boolean A_0)
    at il.b()
    at CThru.Silverlight.SilverlightUnitTestAttribute.Init()
    at CThru.Silverlight.SilverlightUnitTestAttribute.Execute()
    at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
    at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
    at Tests.TestA.SomeTestAgainstSilverlight() in TestA.cs: line 21
在NUnit中运行测试时,我得到:

Tests.TestA.SomeTestAgainstSilverlight:
System.DllNotFoundException : Unable to load DLL 'agcore': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

at MS.Internal.XcpImports.Application_GetCurrentNative(IntPtr context, IntPtr& obj)
at MS.Internal.XcpImports.Application_GetCurrent(IntPtr& pApp)
at System.Windows.Application.get_Current()
at ViewModelExample.ViewModel.ViewModelBase.get_IsDesignTime() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\ViewModelBase.cs:line 20
at ViewModelExample.ViewModel.PeopleViewModel..ctor(IServiceAgent serviceAgent) in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 28
at ViewModelExample.ViewModel.PeopleViewModel..ctor() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 24
at Tests.TestA.SomeTestAgainstSilverlight() in C:\Documents and Settings\USER\Desktop\ViewModelExample\Tests\TestA.cs:line 22

更新:我没有关注这个问题。我换了其他工具

此消息看起来像是文件不匹配问题。尝试从头开始创建一个新的测试项目

首先添加对Typemock.dll和Typemock.ArrangeActAssert.dll的引用。从CThru目录添加CThru.dll和CThru.Silverlight.dll

添加对位于C:\Program Files x86\reference Assembly\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll的System.Windows的引用

尝试创建新的测试方法,并使用SilverlightUnitTest属性对其进行修饰:

using NUnit.Framework;
using CThru.Silverlight;

[TestFixture]
public class SilverlightTest
{
    [Test, SilverlightUnitTest]
    public void EmptyTest()
    {

    }
}

运行这个空测试。如果您仍然存在所描述的问题,请联系typemock.com上的支持部门以获得进一步帮助。

我认为这是SL和.NET 4.0核心DLL之间的冲突。您可以尝试通过从项目文件中配置系统级dll引用hintPath并使用“extern alias”来解决此问题。