Unit testing
-
Over at How to unit test with functions loaded from win32 api? OP wants to unit test "some functions that use calls to functions derived form win32 api and securitybaseapi, specifically LogonUserW and ImpersonateUser." And the basic solution is to provide an "abstraction" substitute for those functions when testing.
I don't get this. The side-effects of and intentions when using
LogonUserW
/ImpersonateUser
are so "enormous" that I cannot imagine how any "abstraction" substitute would lead to any meaningful continuation from or behaviour in the code? Why would these be in the code in the first place? Because, say, the very next line/rest of the function has to run as the new user to do anything or produce required behaviour, or perhaps the whole of future code must be running as the desired user from then on or for a while. How would a substitute which essentially does nothing or does not change the user prove anything in a test? It might check the parameters but that's about it.