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

I have a class "Abc", in which I have some read only property (Context). In constructor of "Abc" class I am setting value to read only property using a private variable (_context). e.g Abc() {_context=new Xyz();}

I want to create a test case, in which I want to mock Xyz class and return value to _context. So that I can fill context using some fake data.

Kindly let me know is it possible to mock class with values. Thanks
asked by sony (7.2k points)

1 Answer

0 votes
Did you try to reate a fake for Xyz, and use an Isolate.Swap.NextInstance() statement? This will cause the instance created in the Abc constructor to be replaced with the fake behavior.
answered by doron (16.5k points)
...