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

发布于 2024-09-01 22:03:39 字数 2495 浏览 5 评论 0原文

我用的是VS2010。 Silverlight 4、NUnit 2.5.5 和 TypeMock TypemockIsolatorSetup6.0.3.619.msi

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

如果您使用其他产品进行 MVVM Silverlight 单元测试,请告知。或者请帮助赢得这个 TypeMock。 TIA

这是测试的代码:

[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

更新:我没有遵循问题。我已改用其他工具。

I'm using VS2010. Silverlight 4, NUnit 2.5.5, and TypeMock
TypemockIsolatorSetup6.0.3.619.msi

In the test project MVVM is implemented, PeopleViewModel is a ViewModel which I want to test.

Please advise if you use other products for unit testing of MVVM Silverlight. Or please help to win this TypeMock. TIA

This is the code of the test:

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

    Assert.AreEqual(15, res.Count());
}

While running the test in ReSharper i get the following error:

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

While running test in NUnit i get:

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

UPDATE: I'm not following the question. I've switched to other tools.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-09-08 22:03:39

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

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

添加对 System.Windows 的引用(位于 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll >)。

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

using NUnit.Framework;
using CThru.Silverlight;

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

    }
}

运行此空测试。如果您仍然遇到所描述的问题,请联系typemock.com 的支持人员以获得进一步帮助。

This message looks like a mismatched files issue. Try creating a new test project from scratch.

Start by adding references to Typemock.dll and Typemock.ArrangeActAssert.dll. From the CThru directory add both CThru.dll and CThru.Silverlight.dll.

Add a reference to System.Windows (located at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll).

Try creating a new test method, and decorate it with SilverlightUnitTest attribute:

using NUnit.Framework;
using CThru.Silverlight;

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

    }
}

Run this empty test. If you're still having the problem you described, please contact support at typemock.com for further assistance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文