Created
April 6, 2018 20:50
-
-
Save alx9r/824f89d0badc27cc9a3defc1d3293cda to your computer and use it in GitHub Desktop.
Example of mocking in nested modules for pester/Pester#1017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
RootModule = 'NestedMock.psm1' | |
ModuleVersion = '0.1.0' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module $PSScriptRoot\NestedMock1.psm1 | |
Import-Module $PSScriptRoot\NestedMock2.psm1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module NestedMock -Force | |
Describe 'nested mock' { | |
InModuleScope NestedMock1 { | |
Mock f2 -Verifiable { Write-Host 'mock called' } | |
f1 | |
It 'invoked mock' { | |
Assert-MockCalled f2 | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f1 { | |
f2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f2 {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment