Supposing that class A is the development code; and so for unit-testing purpose I create a mock for it. But I don't know how to override A's constructor such that it will not get executed in my unit-test code.PHP Code:using namespace System;
ref class A
{
public:
A(){Console::WriteLine(L"A constructor");}
virtual void func(){foo();}
void foo()
{
Console::WriteLine(L"A from foo");
}
};
ref class A_Mock:public A
{
public:
virtual void func() override
{
Console::WriteLine(L"A_MOCK");
}
};
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
A^b=gcnew A_Mock();
b->func();
return 0;
}
Thank you.




Reply With Quote