I mean a test needs to be predictable. It's not something that should run differently in different situations. You call `SetupDiOpenDevRegKey`, that is expected to succeed, if it doesn't, the test should hit an assert and abort, not continue. If it didn't assert, you just close the handle returned.

Basically that `if` should be: `assertTrue(hDeviceKey != INVALID_HANDLE_VALUE);`