How can I unit test a managed wrapper around C code?

I will create a Managed-C ++ wrapper around some C functions to enable its use in other .NET solutions. I look at providing a very minimalist wrapper, something like:

Signature in title C:

void DOSTH(const char*, short, long*);

Open Managed Interface:

public void doSomething(String^ input, short param, [Out] long^ %result);

To do this, my solution will have C headers and will reference a .dll containing the compiled C API that I am creating against.

As a newbie to Visual Studio, I don't know how I could unit test this. Is it possible to mock .dll to provide a mock implementation? Is there a library that will simplify this task? Is there a specific solution structure that I should strive for to make this easier?

Any guidance in this area would be great. Google searches left me wanting more information about hardware testing of a managed wrapper.

+5
source share
2 answers

In some cases (restrictions on tools and / or the complexity of dependencies comes to my mind), a mocking dependency using external frameworks is out of the question. Then there is a completely legal technique for writing layouts manually (I think it was a way to do something before mocking frameworks became popular).

, - , C. - .

( , , - , , ), , / . (stubbing/mocking) - .

, - , , . ( , ) / ( DLL , , , ... ?).

+2

/ , DLL?

, , dll, , . , Moq Rhino.Mocks .

0

All Articles