Our company has multiple Powershell custom actions that we would like to unit test using Pester. We are having trouble doing so due to the atypical behaviors of the cmdlets AI_GetMsiProperty and AI_SetMsiProperty. These are the approaches we've considered/tried:
1. Wrap AI_GetMsiProperty in a function to mock the function: AI_GetMsiProperty won't accept variables for values
2. Wrap AI_GetMsiProperty in a module and import the module: I do not believe Advanced Installer will pick up external modules. Also, same problem as in #1.
Additionally, mocking validation appears that it won't work because AI_GetMsiProperty does not have any named parameters, so we can't validate using Pester's ParameterFilter syntax. I tried using using Get-Command during installer execution to find AI_GetMsiProperty/AI_SetMsiProperty property names, and while we did see something such as $name $value for AI_SetMsiProperty and $name $test1 for AI_GetMsiProperty, attempting to call AI_GetMsiProperty -name <PROPNAME> did not work. Finally, I get a CommandNotFoundException when I attempt to mock the cmdlets by themselves.
My general question is: has anyone had any luck mocking the cmdlets with Pester? Are there any guidelines for how we can test Powershell scripts that use the get/set MSI cmdlets?
FOLLOW US
Get the latest news in Application Packaging