tags:

views:

95

answers:

1

I have a library written in c++ that I want to end-to-end test from C# via interop. Basically this library takes in some parameters and spits out a file at the other end. I want to pass requests to a com interop and then assert that all the data was written correctly to the file.

Is it possible to do this? Is there an easier way? Using pinvoke or something?

Thanks

+1  A: 

I'd use C++/CLI for gluing together .net tests and native C++ code.

It works well enough in practise : I had a similar issue some months ago -- wanting to verify that a C++ protocol library I'd written would be interoperable with an existing Java implementation. For that I used a thin C++/CLI shim to the C++ code, built the Java as J#, and wrote tests in C#.

Steve Gilham
So when you say glue them together using c++ do you mean create a c++ class that calls the system under test and is used to perform the necessary assertions?Could you explain in a little more detail how you implemented it?
Sean Chambers
The C++/CLI layer was a class with static methods that simply delegated calls to the native API (and did any necessary things like converting incoming CLR types to native -- mainly System::Byte[]^ to char[]). The C# unit tests then called the C++/CLI class inconjunction with the J# classes.
Steve Gilham