Developer Tip: Add a blank macro so testers can inject code
While I was working on writing some API tests for a module that was being integrated into the Xbox Dashboard application, there was some rework to the class that happened in the middle process. In doing so, the developer decided to make a bunch of the functionality private, causing my existing test to fail to build (as they no longer had access to anything). Luckily the developer left me a little cookie in his code:
#ifndef CONNECTION_POOL_TEST_FRIENDS
#define CONNECTION_POOL_TEST_FRIENDS()
#endif
class CDdlConnectionPool
{
...
CONNECTION_POOL_TEST_FRIENDS();
};
By providing a blank macro inside the class, he gave me the opportunity to modify the class without having to change the header file. I just have to define the CONNECTION_POOL_TEST_FRIENDS macro from my test code before including the above header file, and I can inject my own friendliness:
// enable the API test to be a "friend" of the connection pool
#define CONNECTION_POOL_TEST_FRIENDS \
friend HRESULT Pool_InitializeTest(void); \
friend HRESULT Pool_AddEntryTest(void);
#include <dashdl.h>
I like cookies.