The current product I work on is a Windows Service written in C++ and going forward all new functionality will have unit tests written for it. But this creates an interesting problem (for me at least) we do a lot of Win32 calls for various things and behave accordingly, so for the unit tests to be complete it would be nice to test a variety of outputs, not just the current system state.
My question is what is the best way to mock the results of the Win32 calls? I have thought about two different methods:
1) Put all the Win32 calls used into function pointers and pass them into the functions or classes (depending on how many times they are hit) that use them and use this to get mock results.
2) Have lots of #ifdef UNITTEST
everywhere and if it is calling my own special methods or have the normal ones called if not.
Am I completely off base here, or missing a fundamental piece of knowledge?