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
Hi,

Using TypeMock 3.1.4 I've tried to use TypeMock in our project, but when I try calling ExpectCall or any other method for that matter on the Mock object, I keep getting this error:

error C3252: 'ad::a' : cannot reduce accessibility of a virtual method in a managed type c:program files ypemock ypemock.net ypemock.dll 1

Of course I would have loved using the latest version, but that one just fails miserable during some constructor call (described in another posting, and I can't remember what they were right now).

Right now I see no option but to bail out on TypeMock :-(.... does anyone have a suggestion/workaround?
asked by bugs (720 points)

6 Answers

0 votes
Hi
We need more details to find the problem. :shock:
Can you please post a code example that generates this message?
answered by ohad (35.4k points)
0 votes
One little detail that may be the cullpritt of the problem: we're using C++/CLI in this project, and C# is (much to my dismay) not allowed - but again, it really shouldn't matter.

#pragma once

using namespace System;
using namespace System::IO;
using namespace NUnit::Framework;
using namespace TypeMock;


namespace TypeMockTest 
{
    [TestFixture]
    public ref class FileInfoEnumeratorTest
    {
    public:
        [Test]
        void Iter1()
        {
            MockManager::Init();
            Mock ^dinfo = MockManager::Mock(DirectoryInfo::typeid);
            dinfo->ExpectCall("GetFileSystemInfos");
            
            MockManager::Verify();
        }
    };
}


I then tried installing TypeMock 3.5.2.0 instead, but it gives the same error.

Then, just for the sake of it, I commented out all code inside "Iter1()", and ran the empty test through nunit-console and tmockrunner. Result being an exception:

E:TypeMockTestdebug>tmockrunner nunit-console TypeMockTest.dll
NUnit version 2.2.8
Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole.
Copyright (C) 2000-2003 Philip Craig.
All Rights Reserved.

OS Version: Microsoft Windows NT 5.1.2600 Service Pack 2    .NET Version: 2.0.50727.42

.F
Tests run: 1, Failures: 1, Not run: 0, Time: 0.625 seconds

SetUp/TearDown Failures:
1) TypeMockTest.FileInfoEnumeratorTest : The type initializer for '<Module>' threw an exception.
   at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPt
r declaringType)
   at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, Runtime
TypeHandle declaringType)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object
[] parameters, CultureInfo culture)
   at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
   at NUnit.Core.Reflect.Construct(Type type)
   at NUnit.Core.TestFixture.DoFixtureSetUp(TestResult suiteResult)

Failures:
1) TypeMockTest.FileInfoEnumeratorTest.Iter1 : TestFixtureSetUp Failed
[/code]
answered by bugs (720 points)
0 votes
Hi
First thank you for your report. 8)
We found the bug.
We are working now on fixing it and I will send you the patch immediately when its ready.
answered by ohad (35.4k points)
0 votes
One week later :-)

I was wondering how the bugfixing goes - or to be more precise; how long until an update (approximate)?

It is a bit unfortunately that it doesn't work, as the company I'm at would be willing to buy quite a few licenses if only it worked. As it is now, I can't even make a single test case to convince 'em.... oh well, not my loss :-)
answered by bugs (720 points)
0 votes
Hi
If you installed the paches I sent you, you should be able to compile your test.
There is however the problem of mocking mscorelib types ...
The solution is to wrap the use of mscorlib in a method and mock the method class.


   public class ClassUseingCoreLib
   {
   public:
      void Func()
      {
         DirectoryInfo^ dInf = gcnew  DirectoryInfo("d:\tst");
         array<FileSystemInfo^>^ fInf =  dInf->GetFileSystemInfos();
         //...
      }
   };


And then your test will be:

    [TestFixture]
    public ref class FileInfoEnumeratorTest
    {

   public:
      [Test]
      void Iter2()
      {
         MockManager::Init();
         Mock ^dinfo = MockManager::Mock(ClassUseingCoreLib::typeid);
         dinfo->ExpectCall("Func");
         ClassUseingCoreLib CoreUser;
         CoreUser.Func();
         MockManager::Verify();
      }
    };
answered by ohad (35.4k points)
0 votes
Hi,

I've finally had the time ti re-visit the tests (been working on other stuff). The update seems fine - at least so far I've been able to run all my previous testcases through tmockrunner without problems. Furthermore I've had the pleasure of implementing a few testcases that actually uses mocking - they also seem to work like a charm :)

All in all, looks like a nice update that does the trick. Now, off to the managers to request a license for the commercial version.

And yes, support works like a charm.

BR Johnny
answered by bugs (720 points)
...