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
This worked without issue in 5.2 or 5.3??? I can't remember what this was written against when it worked as we haven't worked with this libary in some time. I had to make a change today and we are currently on 5.4.4 so I had to update my references and now fails. This is inside of a test helper method that I call from many tests.

DbConnection fakeConnection = Isolate.Fake.Instance<DbConnection>(l);
DbCommand fakeCmd = Isolate.Fake.Instance<DbCommand>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => Utilities.CreateConnection()).WillReturn(fakeConnection);
Isolate.WhenCalled(() => fakeConnection.CreateCommand()).WillReturn(fakeCmd);


The error you will receive on the first and second line:
System.TypeLoadException: Declaration referenced in a method implementation cannot be a final method. Type: 'Mock0008DbCommand'. Assembly: 'DynamicMockAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a0857b23fb3f20d9'.



I worked around this by creating two stub classes:
FakeDbConnection (inherits from DbConnection) and FakeDbCommand (inherits from DbCommand) and then just changed my code to the following:

DbConnection fakeConnection = Isolate.Fake.Instance<FakeDbConnection>();
DbCommand fakeCmd = Isolate.Fake.Instance<FakeDbCommand>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => Utilities.CreateConnection()).WillReturn(fakeConnection);
Isolate.WhenCalled(() => fakeConnection.CreateCommand()).WillReturn(fakeCmd);
asked by boo (21.8k points)

3 Answers

0 votes
Hi,

It seems that this issue is fixed in our upcoming version that will be out soon :)
I'm sending you a preview please check out it out and let me know if it solves the problem.
answered by ohad (35.4k points)
0 votes
Hi,

In which version of Typemock is this issue fixed. We are currently using Typemock 5.4.5 and running into the same issue.
answered by mk_typemock (180 points)
0 votes
Hello,

This issue is fixed in version 6.0 of Isolator. Try downloading the latest version of Isolator from http://site.typemock.com/typemock-isolator-product/

Let me know if this solves the problem you're experiencing.
answered by igal (5.7k points)
...