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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hello,

I experience an issue with Isolate.WhenCalled. Suppose I have, in assembly A, a class that does:

public class MyCollection<T> : IList<T>
{
public virtual void Add(T item) { .. }

.
.
}

Assembly B references assembly A, and defines:

public class NewCollection : MyCollection<NewObj>
{

}

Notice it does not override Add. When I do in a test:


[Test]
public void TestColl()
{
var coll = Isolate.Fake.Instance<NewCollection>();
Isolate.WhenCalled(() => coll.Add(null)).CallOriginal();
}

This throws an exception. I don't have the stack trace handy, but it was looking for a reference to the method in a generic dictionary, and it couldn't find it. However, if in NewCollection i override the Add method (and simply return the base implementation), then this works fine.

Why is that?

Thanks.
asked by bmains (13.2k points)

4 Answers

0 votes
Hi Brian,

I tried the example you posted and it doesn't throw an exception.
Can you please tell me what version of the Isolator are you using?
What line throws the exception?
answered by ohad (35.5k points)
0 votes
5.3.0.0 - It doesn't step into the add method; it just errors, without giving me cause...
answered by bmains (13.2k points)
0 votes
Hi,

I was not able to reproduce it in version 5.3.0.0, let's take it offline and continue there.

Regards,
Elisha
Typemock Support Team
answered by Elisha (12k points)
0 votes
After upgrading to the latest version, the problem did not resurface.
answered by gilz (14.5k points)
...