Skip to content

Mocking cmdlet with dynamic parameters not working #339

Description

@abhinitmodi

Hey,
I am trying to use an azure-commandlet which uses dynamic parameters. The commandlet is new-azureresourcegroupdeployment. I am mocking it in the following way

Mock New-AzureResourceGroupDeployment { throw "No appropriate mock called for New-AzureResourceGroupDeployment" }
Mock New-AzureResourceGroupDeployment -MockWith { return $validResourceGroupDeployment } -ParameterFilter{$Name -eq $validResourceGroupName -and $ResourceGroupName -eq $validResourceGroupName -and $TemplateFile -eq $validTemplatePath}

But when I run my tests, I get the exception:

Cannot retrieve the dynamic parameters for the cmdlet. Exception calling "GetDynamicParameters" with "0" argument(s): "Object reference not set to an instance of an object

Am I missing something. Could you please point me to an example where you have mocked a commandlet which has dynamic parameters. I was using the 3.3.6 version. I upgraded to 3.3.8 and tried again but was not successful.

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions