36 lines
1.7 KiB
PowerShell
36 lines
1.7 KiB
PowerShell
. $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 = ""
|
|
|
|
Describe "Set-AppTierDefaultWebSite" {
|
|
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { "UUT" }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Verbose -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Write-Warning -MockWith { }
|
|
|
|
Mock -ModuleName $moduleForMock -CommandName Get-DefaultWebsite -MockWith { return @{ not = "null";} }
|
|
Mock -ModuleName $moduleForMock -CommandName New-DefaultWebsite -MockWith { }
|
|
Mock -ModuleName $moduleForMock -CommandName Optimize-DefaultWebsite -MockWith { }
|
|
|
|
Context "Website exists" {
|
|
Mock -ModuleName $moduleForMock -CommandName Get-DefaultWebsite -MockWith { return @{ not = "null";} }
|
|
|
|
It "Did not throw and Did not call New-DefaultWebsite" {
|
|
{ Set-AppTierDefaultWebSite } | Should -Not -Throw
|
|
Assert-MockCalled -ModuleName $moduleForMock -CommandName New-DefaultWebsite -Scope It -Times 0
|
|
}
|
|
}
|
|
|
|
Context "Website does not exist" {
|
|
Mock -ModuleName $moduleForMock -CommandName Get-DefaultWebsite -MockWith { return $null }
|
|
|
|
It "Did not throw and Did call New-DefaultWebsite" {
|
|
{ Set-AppTierDefaultWebSite } | Should -Not -Throw
|
|
Assert-MockCalled -ModuleName $moduleForMock -CommandName New-DefaultWebsite -Scope It -Times 1
|
|
}
|
|
}
|
|
} |