I need to stop executing constructor
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;
}
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.
Thank you.
Re: I need to stop executing constructor
What is this weird stuff?
Code:
int main(array<System::String ^> ^args)
Seriously, you want the Managed C++ forum, not this one. There is no such keyword as "ref" in ANSI C++ or "gcnew", or any of the "^" stuff in the C++ language.
This forum is for ANSI C++ using Visual C++, plus use of MFC, ATL libraries. Managed, CLR, or any type of .NET C++ goes in the Managed forum.
Regards,
Paul McKenzie