The parameter $Metadata in Set-DynamicParameterVariables (Mock.ps1: line 1202) is causing a type-conflict for mocked functions that also have a parameter called 'Metadata' (WebAdministration's Set-WebConfiguration particularly).
When this line:
$SessionState.PSVariable.Set($variableName, $keyValuePair.Value) (line 1219)
is called, it won't allow the mocked $Metadata to be set because it thinks it should be of type [System.Management.Automation.CommandMetadata].
One solution is to change the names of the parameters in this function to be more unique so that conflicts such as this don't arise.
Repro:
function Sample {
param(
[string]
${Metadata}
)
}
function Wrapper {
Sample -Metadata 'test'
}
Describe 'Bug in mock' {
Mock -CommandName Sample -MockWith {}
Wrapper
}
The parameter $Metadata in Set-DynamicParameterVariables (Mock.ps1: line 1202) is causing a type-conflict for mocked functions that also have a parameter called 'Metadata' (WebAdministration's Set-WebConfiguration particularly).
When this line:
$SessionState.PSVariable.Set($variableName, $keyValuePair.Value) (line 1219)
is called, it won't allow the mocked $Metadata to be set because it thinks it should be of type [System.Management.Automation.CommandMetadata].
One solution is to change the names of the parameters in this function to be more unique so that conflicts such as this don't arise.
Repro:
function Sample {
param(
[string]
${Metadata}
)
}
function Wrapper {
Sample -Metadata 'test'
}
Describe 'Bug in mock' {
Mock -CommandName Sample -MockWith {}
Wrapper
}