pester/Pester — pull request #248 by dlwyatt (2014-12-30 01:07:16+00:00)
Title: Fix for mocking functions with mandatory pipeline parameters

The dynamicparam code was failing in a situation where a mocked function defined a mandatory parameter that is able to accept pipeline input, and when the call to the mocked function is taking advantage of that pipeline capability.

The script block that is executed to generate any dynamic parameters (even if the mocked function doesn't have any dynamicparam statements, this still gets called) was defining the same param block as the original command, and the $PSBoundParameters table was being splatted to the dynamicparam script block. The problem is that when pipeline input is involved, the input objects haven't been bound yet at the time that the dynamicparam code is executed. Because those parameters were marked as mandatory, this caused the dynamicparam script block to prompt for input (or fail, if -NonInteractive mode is in effect.)

To fix this, I stripped out the Mandatory attribute from all parameters when generating the dynamicparam script block.