108 lines
3.4 KiB
PowerShell
108 lines
3.4 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 "Get-WorkspaceBundleList" {
|
|
|
|
Mock -CommandName Get-AWSRegion -ModuleName $moduleForMock -MockWith { return @( @{ 'Region' = 'us-west-2' } ) }
|
|
Mock -CommandName Import-AWSModule -ModuleName $moduleForMock -MockWith {}
|
|
Mock -CommandName Get-WKSWorkspaceBundle -ModuleName $moduleForMock -MockWith {
|
|
# Build the first test case.
|
|
$test1 = [PSCustomObject] @{
|
|
BundleId = 1
|
|
Name = 'Windows 7'
|
|
Description = 'Test'
|
|
ComputeType = [PSCustomObject] @{
|
|
Name = 'Power'
|
|
}
|
|
}
|
|
|
|
# Build the second test case.
|
|
$test2 = [PSCustomObject]@{
|
|
BundleId = 2
|
|
Name = 'Windows 10'
|
|
Description = 'WorkSpaces Streaming Protocol'
|
|
ComputeType = [PSCustomObject]@{
|
|
Name = 'GRAPHICS'
|
|
}
|
|
}
|
|
|
|
# Build the third test case.
|
|
$test3 = [PSCustomObject]@{
|
|
BundleId = 3
|
|
Name = 'Amazon Linux 2'
|
|
Description = 'PCoIP'
|
|
ComputeType = [PSCustomObject]@{
|
|
Name = 'PERFORMANCE'
|
|
}
|
|
}
|
|
|
|
return @( $test1, $test2, $test3)
|
|
}
|
|
|
|
Context "Parameter Validation" {
|
|
|
|
It "Throws if ProfileName is Null" {
|
|
{ Get-WorkspaceBundleList -ProfileName $null } | Should -Throw
|
|
}
|
|
|
|
It "Throws if ProfileName is Empty" {
|
|
{ Get-WorkspaceBundleList -ProfileName '' } | Should -Throw
|
|
}
|
|
|
|
It "Throws if Region is Not in Supported List" {
|
|
{ Get-WorkspaceBundleList -Region 'Test' } | Should -Throw
|
|
}
|
|
|
|
It "Throws if Owner is Not in Supported List" {
|
|
{ Get-WorkspaceBundleList -Owner 'Test' } | Should -Throw
|
|
}
|
|
|
|
It "Throws if ComputeTypeFilter is Not in Supported List" {
|
|
{ Get-WorkspaceBundleList -ComputeTypeFilter 'Test' } | Should -Throw
|
|
}
|
|
|
|
It "Throws if OsFilter is Not in Supported List" {
|
|
{ Get-WorkspaceBundleList -OsFilter 'Test' } | Should -Throw
|
|
}
|
|
|
|
It "Throws if ProtocolFilter is Not in Supported List" {
|
|
{ Get-WorkspaceBundleList -ProtocolFilter 'Test' } | Should -Throw
|
|
}
|
|
}
|
|
|
|
Context "Logic Validation" {
|
|
|
|
It "Returns All Results With No Filtering By Default" {
|
|
|
|
$results = Get-WorkspaceBundleList
|
|
$results | Should -HaveCount 3
|
|
}
|
|
|
|
It "Applies ComputeTypeFilter If Provided" {
|
|
|
|
$results = Get-WorkspaceBundleList -ComputeTypeFilter 'POWER'
|
|
$results | Should -HaveCount 1
|
|
$results[0].BundleId | Should -BeExactly 1
|
|
}
|
|
|
|
It "Applies OsFilter If Provided" {
|
|
|
|
$results = Get-WorkspaceBundleList -OsFilter 'Windows 10'
|
|
$results | Should -HaveCount 1
|
|
$results[0].BundleId | Should -BeExactly 2
|
|
}
|
|
|
|
It "Applies ProtocolFilter If Provided" {
|
|
|
|
$results = Get-WorkspaceBundleList -ProtocolFilter 'PCoIP'
|
|
$results | Should -HaveCount 1
|
|
$results[0].BundleId | Should -BeExactly 3
|
|
}
|
|
}
|
|
}
|