Calling A method within an abstract class

+1 vote
I'm trying to fake an abstract class and call one its method and it does not work.

the abstract class has a method called : LoadObjectInSession(string key);


I tried the following and each and everytime it returns null ;



var con = Isolate.Fake.AllInstances<BaseController>();

Isolate.WhenCalled(() => con.LoadObjectInSession("myKey")).WillReturn("aaa");


MockObject<BaseController> mockInterface = MockManager.MockObject<BaseController>();


Isolate.WhenCalled(() => mockInterface.Object.LoadObjectInSession("myKey")).WillReturn("aaa");


Please help me understand why everytime it's returning null ?


Thank you
asked Nov 5 by aringan (140 points)

1 Answer

–1 vote
Hey aringan,

First of all, the second example you presented here is an old API, so I wouldn't recommend using it.

When I tested the first example on my machine it worked fine.

Which Typemock version are you using?
answered Nov 5 by SapirTypemock (1,130 points)
my version :

again neither works for me. when it gets to the following line of code :

string result = LoadObjectInSession("myKey");

although expected value for result is "aaa", however it's null


Thank you
Hey aringan,

I'm using version and it works fine for me, so I believe that if you use this version it will work for you too.

Do you have a license key? if so, can you send it to us?