--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
Type ^dateType = DATE::typeid;
DynamicMock dateMock = gcnew DynamicMock(dateType);
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
This works for me:
Type ^dateType = DateTime::typeid;
DynamicMock ^dynamicMock = gcnew DynamicMock(dateType);
To my knowledge, there shouldn't be anything C# can do that wouldn't map
to C++/CLI in one way or another.
-Markus-
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
--
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
Hi Markus, Thank you. That did work. However my code threw an error at the last line Type ^dateType = DATE::typeid; DynamicMock ^dateMock = gcnew DynamicMock(dateType); String ^methodName="split"; dateMock->ExpectAndReturn(methodName, false); int result; result=actual_days_between_dates(%(*dateMock->MockInstance),% (*dateMock->MockInstance)); The error was "error C2664: 'actual_days_between_dates' : cannot convert parameter 1 from 'System::Object ^' to 'const DATE *' No user- defined-conversion operator available, or Cannot convert a managed type to an unmanaged type" the method I'm testing is "int actual_days_between_dates(const DATE *start_date, const DATE *end_date)"
class DATE
{
public: virtual int split() const {}
};
int main(array<System::String ^> ^args)
{
Type ^dateType = DATE::typeid;
Console::WriteLine(dateType->ToString());To dynamically mock C++ classes, I believe you will need to either manually write a mock or find a C++ mock library. I'm not aware of any such libraries, but I haven't done much testing in C++ at all. It's not impossible to do (take method pointer in C++, offset pointer into a vtable, copy vtable, override method), so I'd expect someone should already have built a library to do this out there.
array<MethodInfo ^> ^methodInfos = dateType->GetMethods();
for(int index = 0; index < methodInfos->Length; ++index) {
Console::WriteLine(methodInfos[index]->ToString());
}
return 0;
}
-Markus--Saritha.
To dynamically mock C++ classes, I believe you will need to either manually write a mock or find a C++ mock library. I'm not aware of any such libraries, but I haven't done much testing in C++ at all. It's not impossible to do (take method pointer in C++, offset pointer into a vtable, copy vtable, override method), so I'd expect someone should already have built a library to do this out there.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.