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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
Hi,

I am facing strange error when using Isolate.Whencalled. I am having some classes on c# and some classes in C++/CLI as mentioned below. and facing an error when trying to fake one of the class instance (Please see Unit test code in the below)

Below are the classes I have

1.dll - c#
-----------
class1
{
void somemethod()
{
class2.Instance().somemethod();
}

int Init()
{
class2.Instance().Init();
}
}

2.dll - c++ /cli - singleton
-----------------------------
class2
{
class3 cls3;
void somemethod()
{
cls3 = new cls3();
}

int Init()
{
cls3.Init()
}
}

c# - class
-----------------------
class3
{
int Init()
{
class4 cls 4 = new class4()
cls4.Init() //Issue is coming here saying cannot load assembly or file 3 or //its depandcies
}
}


3.dll - c++ /cli
------------------
class4
{
int Init()
{
}
}


Unit Test code - Added ref to 1.dll && 2.dll
---------------------------------------

class3 fake = Isolate.Fake.Instance<class3>();
Isolate.Swap.NextInstance<class3 >().With(fake);

Isolate.WhenCalled(() => fake.Init()).WillReturn(1);
//But here it is throwing an error as mentioned above

Please help me ASAP
asked by (6.1k points)

1 Answer

0 votes
Hi,

Please make sure that all the c++\cli projects are configured to be win32 and all c# are x86.

You can set it in Visual Studio: Build menu -> Configuration manager.

Let me know if it helps.
answered by (18k points)
...