We are trying to assert a call with specific parameter which is an array and it's returning false in Assert-MockCalled, for all other parameters which are not array it's working (string types).
Here is my example:
function NewZip ($Name) {
$compress = @{
Path = "$PSScriptRoot/terms.txt", "$PSScriptRoot/fav.ico"
CompressionLevel = "Fastest"
DestinationPath = "$PSScriptRoot/$Name.zip"
}
Compress-Archive @compress -Update
}
It "Creates a zip file" {
# Arrange
$name = "test"
$assertParams = @{
CommandName = 'Compress-Archive'
Times = 1
ParameterFilter = {
$Path -in "$PSScriptRoot/terms.txt", "$PSScriptRoot/fav.ico" -and
$DestinationPath -eq "$PSScriptRoot/$name.zip" -and
$CompressionLevel -eq "Fastest" -and
$Update -eq $true
}
}
Mock Compress-Archive {}
# Act
NewPackage -Name $name
# Assert
Assert-MockCalled @assertParams
}
How can I use array comparison within Assert-MockCalled?