views:

64

answers:

1

Create Pex test to test a DLL and hardware controlled by that DLL?

I have some hardware that has an api in that is controlled by a DLL. I have written some unit tests in nunit that will call the appropriate pieces of the API and do a test.

For instance I might have a "get data test", that has an 1. open, 2. read on one side and 3. send on the other, and the assert is whether or not the data is correct.

I am thinking Pex might do a good job of manipulating that data piece.

My question is since I am sitting on top of a DLL and I really need to piece several things together for the test how do I implement Pex here (I also know next to nothing of Pex at this time)?

Do I somehow need to create an API that I control above the DLL that has read and sends and let Pex go at this layer to create it's test?

Edit: I did some more research and watched a great video over at http://channel9.msdn.com/posts/Peli/Getting-started-with-Pex-in-Visual-Studio-2008/

I am questioning the ability to do this. Sounds like Pex will be great to create tests but not really a whole system (api plus hardware plus data)

+1  A: 

It has to instrument the code to generate the tests, so it won't reach the external behaviors. If your API is v. thin and doesn't do much then you won't get much from it.

If you have a fair amount of logic in that api along with the hardware calls, I would separate all of that from the code that does the actual interaction with the hardware - defining an interface and using that in the rest of the code. That will allow you to use on all the logic involved.

The above includes separating stuff like parsing/analyzing data from sending / receiving. You will be able to cover all that.

eglasius