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 ;

 

1)

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

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

2)

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

mockInterface.ExpectUnmockedCall("LoadObjectInSession");

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 : 8.6.0.10

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 8.6.0.18 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?
...