Skip to content

Instantly share code, notes, and snippets.

@gerane
Created June 15, 2016 14:52
Show Gist options
  • Select an option

  • Save gerane/19f1816480a0b71a1c7d7db8225cedd5 to your computer and use it in GitHub Desktop.

Select an option

Save gerane/19f1816480a0b71a1c7d7db8225cedd5 to your computer and use it in GitHub Desktop.
# Is there a reason why one might use Example 1 over Example 2 if only using a single command?
## Example 1
New-Module -Name SomeModule -Function "SomeFunction" -ScriptBlock { Function SomeFunction { Write-Host "Invoking SomeFunction with $params"} } | Import-Module
## Example 2
Function SomeFunction { Write-Host "Invoking SomeFunction with $params"}
## Example Usage
Describe "Invoke-Something" {
It 'Mocks a Dependency' {
Mock SomeFunction {}
$Results = Invoke-Something -param1 $param1 -Param2 $param2 -Verbose -Force
$Results | Should be 'Something'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment