Reputation: 521
My program reads registry keys under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes.
When I execute unit test from VS2010, the key can not be opened
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer
can be opened without any problems, but it has no subkeys.
When I execute my program, it works well.
I suppose there is a rights issue with units tests... Do you know, if it is possible to execute unit tests with admin rights?
I've tried already to start VS as Administrator and switched off UAC.
Upvotes: 0
Views: 103
Reputation: 10221
You should think to registry as a system dependency, so you need to abstract theme in your design, then moq it to test.
Anyway this is a possible duplicate of: Mocking the Registry - SystemWrapper
Upvotes: 1