chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
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.

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


I'm investigating how we can conduct unit testing of Silverlight UI. And I hope TypeMock (CThru.Silverlight) will mange it.

TIA
asked by 1gn1ter (600 points)

6 Answers

0 votes
I'd like to further investigate this issue - can you send a test project that shows this issue to support AT Typemock.com
answered by dhelper (11.9k points)
0 votes
I has similar problem with VS2010, Typemock Isolator from today and Resharper 5 in Vista64:
    public enum DesignMethod
    {
        Etag,
        Aci318_02,
        Aci318_05
    }

    public class Method
    {
        public DesignMethod DesignMethod { get; set; }

        public Method(DesignMethod designMethod)
        {
            DesignMethod = designMethod;
        }

        public override string ToString()
        {
            return DesignMethod.ToString().Replace("_", " ");
        }
    }

Testclass:
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            var dm = new Method(DesignMethod.Etag);
            Assert.AreEqual("Etag", dm.ToString());
        }
        [TestMethod]
        public void TestMethodAci()
        {
            var dm = new Method(DesignMethod.Aci318_02);
            Isolate.WhenCalled(() => dm.ToString()).WillReturn("Test");

            Assert.AreEqual("Aci318 02", dm.ToString());
        }
    }

Starting tests using VS Test window: expected result
Starting single tests using Resharper: expected result
Starting tests using Resharper: failed with
Die TestProject1.UnitTest1.TestMethodAci-Testmethode hat eine Ausnahme ausgelöst: TypeMock.TypeMockException: 
*** No method calls found in recording block. Please check:
 * Are you trying to fake a field instead of a property?
 * Are you are trying to fake mscorlib type?
bei f3.a(cf A_0, Boolean A_1)
bei c2.a(Boolean A_0)
bei c8.b(Boolean A_0)
bei h9.c(Boolean A_0)
bei h9.a(Object A_0, Boolean A_1, Func`1 A_2, Action A_3, Action A_4, Action A_5)
bei h9.c(Object A_0)
bei TypeMock.ArrangeActAssert.ExpectationEngine`1.a(TResult A_0)
bei TestProject1.UnitTest1.TestMethodAci() in UnitTest1.cs: line 24.


Can you help?

Mario Noack
answered by marionoack (220 points)
0 votes
Marionoack,

This does not seem to be the same issue. The different results between running one test or both tests indicates this may be a cleanup issue. Can you try to put the [Isolated] attribute on the test class, or on all specific tests that use the Isolator API? This will ensure behaviors set in one test will not leak to the next.

Please let me know if this helped resolve the issue.

Thanks,
Doron
Typemock Support
answered by doron (16.5k points)
0 votes
I have assigned the attribute to method: No change
I have assigned the attribute to method+class: No change
I have assigned the attribute to class: No change

All "Run All Tests" from Resharper fails with TypeMock.TypeMockException.
answered by marionoack (220 points)
0 votes
I test it again:

VS2008 + R#5 + no attribute
"Run All Tests" with R# works

VS2010 + R#5 + NET4 + with/no attribute
"Run All Tests" with R# fails with TypeMock.TypeMockException.

I hope you can reproduce it. Can you?

Thank, Mario
answered by marionoack (220 points)
0 votes
Mario,

Let's take this offline. Can you email me the code that recreates this issue to support(at)typemock.com? I will work to create a local reproduction.

Thanks,
Doron
Typemock Support
answered by doron (16.5k points)
...