. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" $databaseModule = 'Alkami.PowerShell.Database' # define some common parameters so we can refer to them $migrationRunnerPath = 'C:\This\Is\A\Path\runner.exe' $migrationTypeName = 'choco' $runtime = 'framework' $packageId = 'testpackage' $packageVersion = '0.0.1' $feed = 'http://test.domain/feed/url' $connectionString = 'Pretend this is a valid connection string' $dbmsUser = 'domain\gmsa.account$' $databaseServiceAccount = 'ServiceAccountPrefix' $subscriptionhost = '127.0.0.1' $orbMigrateFolderPath = 'C:\This\Is\A\Path\Migrations' $tempFolder = 'C:\Windows\Temp' $environmentType = 'Pester' $logFileFolder = 'C:\This\Is\Not\A\Path' $bankGuids = [Guid]::NewGuid().Guid,[Guid]::NewGuid().Guid # This is specifically a string-with-spaces so we can bypass "required" parameters so we can validate them elsewhere (if we validate them at all) $missing = " " Describe "Invoke-AlkamiMigrationRunner_TeamCityInstallPackages" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } Context "Invalid parameters provided - Feed is provided" { It "throws" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName $MigrationTypeName -PackageId $PackageId -PackageVersion $PackageVersion -PackageFeed $Feed -ConnectionString $missing -DbmsUser $missing -SubscriptionHost $missing -TempFolder $missing -EnvironmentType $missing } | Should -Throw } It "Called Write-Warning for each invalid parameter passed above with `$missing" { # Feed is provided Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 5 -Scope Context } } Context "Invalid parameters provided - Feed is not provided" { It "does not throw" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName $MigrationTypeName -PackageId $packageId -PackageVersion $packageVersion -PackageFeed $missing -ConnectionString $missing -DbmsUser $missing -SubscriptionHost $missing -TempFolder $missing -EnvironmentType $missing -BankGuids $missing } | Should -Throw } It "Called Write-Warning for each invalid parameter passed above with `$missing" { # Feed is not provided Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 6 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName $MigrationTypeName -PackageId $PackageId -PackageVersion $PackageVersion -PackageFeed $Feed -ConnectionString $ConnectionString -DbmsUser $DbmsUser -SubscriptionHost $SubscriptionHost -TempFolder $TempFolder -EnvironmentType $EnvironmentType -BankGuids $BankGuids -LogTeamCityMessages -NoTeamCityBlockMessages -NoTeamCityBuildProblems -NoTeamCityMessages -LogErrorsAsWarn} | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 0 -Scope Context } It "Calls Get-ValidatedRuntimeParameter" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "Validish parameters provided - With logging" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName $MigrationTypeName -PackageId $PackageId -PackageVersion $PackageVersion -PackageFeed $Feed -ConnectionString $ConnectionString -DbmsUser $DbmsUser -SubscriptionHost $SubscriptionHost -TempFolder $TempFolder -EnvironmentType $EnvironmentType -BankGuids $BankGuids -LogFileFolder $logFileFolder } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 0 -Scope Context } It "Calls Get-ValidatedRuntimeParameter" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Calls Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 1 -Scope Context } } } Describe "Invoke-AlkamiMigrationRunner_Runtime" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { return 'ignored' } # Tom, why does this not work? # Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { return 'ignored' } Mock -ModuleName $databaseModule -CommandName Get-ValidatedRuntimeParameter -MockWith { return 'ignored' } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } # Technically this relies on missing the value PackageId because it's an empty string # This is really more of a hello-world test Context "Missing parameters - PackageId" { It "throws because a required parameter is not provided" { { Invoke-AlkamiMigrationRunner -Runtime $runtime -PackageId "" -PackageVersion $packageVersion } | Should -Throw } } Context "Few parameters but enough" { It "Seems to have enough parameters to work on developer machines" { { Invoke-AlkamiMigrationRunner -Runtime $runtime -PackageId $packageId -PackageVersion $packageVersion } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } # Tom, why does this not work? It "Calls Get-ValidatedRuntimeParameter" -Skip { Assert-MockCalled -Module $databaseModule -CommandName Get-ValidatedRuntimeParameter -Times 1 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "A lot of parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -Runtime $runtime -PackageId $packageId -PackageVersion $packageVersion -ConnectionString $connectionString -DbmsUser $dbmsUser -SubscriptionHost $subscriptionhost -TempFolder $tempFolder -EnvironmentType $environmentType -BankGuids $bankGuids } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } # Tom, why does this not work? It "Calls Get-ValidatedRuntimeParameter" -Skip { Assert-MockCalled -Module $databaseModule -CommandName Get-ValidatedRuntimeParameter -Times 1 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } } Describe "Invoke-AlkamiMigrationRunner_ORB" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { return "ignored" } Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } Context "Invalid parameters - ConnectionString" { It "throws" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "orb" -ConnectionString " " -OrbMigrateFolderPath "not a path" } | Should -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "orb" -ConnectionString $connectionString -OrbMigrateFolderPath $orbMigrateFolderPath } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "orb" -ConnectionString $connectionString -OrbMigrateFolderPath $orbMigrateFolderPath -LogFileFolder $logFileFolder } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Calls Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 1 -Scope Context } } } Describe "Invoke-AlkamiMigrationRunner_GrantRoleTenants" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { return "ignored" } Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } Context "Invalid parameters - ConnectionString" { It "throws" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRoleTenants" -ConnectionString " " -DatabaseServiceAccount $databaseServiceAccount -TenantRoleName "blarg"} | Should -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRoleTenants" -ConnectionString $connectionString -DatabaseServiceAccount $databaseServiceAccount -TenantRoleName "blarg" } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRoleTenants" -ConnectionString $connectionString -DatabaseServiceAccount $databaseServiceAccount -TenantRoleName "blarg" -LogFileFolder $logFileFolder } | Should -Not -Throw } It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRoleTenants" -ConnectionString $connectionString -DatabaseServiceAccount $databaseServiceAccount -TenantRoleName @("blarg","poof") -LogFileFolder $logFileFolder } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Calls Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 1 -Scope Context } } } Describe "Invoke-AlkamiMigrationRunner_DbUserCreate" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { return "ignored" } Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } Context "Invalid parameters - DataSource" { It "throws" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "DbUserCreate" -DataSource " " -DatabaseName "not a DB" -DbmsUser "not a user" } | Should -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "DbUserCreate" -DataSource "not a server" -DatabaseName "not a DB" -DbmsUser "not a user" } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName "DbUserCreate" -DataSource "not a server" -DatabaseName "not a DB" -DbmsUser "not a user" -LogFileFolder $logFileFolder } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Do not call Get-MigrationRunnerExe because we supplied the path" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 0 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Calls Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 1 -Scope Context } } } Describe "Invoke-AlkamiMigrationRunner_GrantRole" { Mock -ModuleName $moduleForMock -CommandName Test-Path -MockWith { $true } Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" } Mock -ModuleName $moduleForMock -CommandName Out-File -MockWith { } Mock -ModuleName $moduleForMock -CommandName New-Item -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { } Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { } Mock -ModuleName $moduleForMock -CommandName Get-MigrationRunnerExe -MockWith { return "ignored" } Mock -ModuleName $moduleForMock -CommandName Get-ValidatedRuntimeParameter -MockWith { } Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { return "some content for logging maybe" } Context "Invalid parameters - DataSource" { It "throws" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRole" -DataSource " " -DatabaseName "not a DB" -DbmsUser "not a user" } | Should -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationTypeName "GrantRole" -DataSource "not a server" -DatabaseName "not a DB" -DbmsUser "not a user" } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Called Get-MigrationRunnerExe" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 1 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Does not call Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 0 -Scope Context } } Context "Validish parameters provided" { It "does not throw because it seems to have valid parameters" { { Invoke-AlkamiMigrationRunner -MigrationRunnerPath $MigrationRunnerPath -MigrationTypeName "GrantRole" -DataSource "not a server" -DatabaseName "not a DB" -DbmsUser "not a user" -LogFileFolder $logFileFolder } | Should -Not -Throw } It "Does not call Write-Warning" { Assert-MockCalled -Module $moduleForMock -CommandName Write-Warning -Times 0 -Scope Context } It "Do not call Get-MigrationRunnerExe because we supplied the path" { Assert-MockCalled -Module $moduleForMock -CommandName Get-MigrationRunnerExe -Times 0 -Scope Context } It "Does not call Get-ValidatedRuntimeParameter (because we specified a valid value in the function)" { Assert-MockCalled -Module $moduleForMock -CommandName Get-ValidatedRuntimeParameter -Times 0 -Scope Context } It "Called Invoke-CallOperatorWithPathAndParameters" { Assert-MockCalled -Module $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -Times 1 -Scope Context } It "Calls Out-File" { Assert-MockCalled -Module $moduleForMock -CommandName Out-File -Times 1 -Scope Context } } } Remove-Module -Name $sut.Replace(".ps1","") -Force