Skip to content

Instantly share code, notes, and snippets.

@JohnRoos
Last active May 11, 2020 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnRoos/0549ff530d137ea57fbf1169e2b5f4ad to your computer and use it in GitHub Desktop.
Save JohnRoos/0549ff530d137ea57fbf1169e2b5f4ad to your computer and use it in GitHub Desktop.
#region LabModule.psd1
@{
RootModule = 'LabModule.psm1'
ModuleVersion = '1.0'
GUID = 'd00578f5-fb6b-4c47-83fb-ed1c8d9a1ec2'
FunctionsToExport = 'Get-PublicStuff'
}
#endregion
#region LabModule.psm1
# public function
function Get-PublicStuff {
Get-PrivateStuff
}
# private function
function Get-PrivateStuff {
'This is very private'
}
#endregion
#region LabModule.tests.ps1
Import-Module .\LabModule.psd1 -Force
Describe "LabModule" {
Context "Private functions" {
It "Should invoke private function once" {
Mock Get-PrivateStuff { 'mocked' } -ModuleName 'LabModule'
Get-PublicStuff
Should -Invoke 'Get-PrivateStuff' -Exactly 1 -ModuleName 'LabModule'
}
}
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment