tests/PSPuTTY.tests.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<#
Assuming that this module is in your $env:PSModulePath, you can invoke this Pester test script:

  Set-Location -Path ('{0}\Tests' -f (Get-Module -Name PSPuTTY -ListAvailable).ModuleBase);
  ./PSPuTTY.tests.ps1
#>


$VerbosePreference = 'continue'
$ErrorActionPreference = 'stop'

describe -Name 'PSPuTTY PowerShell module' {
    $ModuleName = 'PSPuTTY'
    $ModulePath = Split-Path -Path $PSScriptRoot -Parent
    if (Get-Module -Name $ModuleName) {
        Remove-Module -Name $ModuleName
    }
    Import-Module -Name $ModulePath -Force
    Write-Verbose -Message ('Module path is: {0}' -f $ModulePath)

    context -Name 'Basic presence of core commands' {
        it 'Should have a Get-PSPuTTYSession command' {
            (Get-Command -Module $ModuleName -Name Get-PSPuTTYSession).Count | Should be 1
        }

        it 'Should have a Get-PSPuTTYTheme command' {
            (Get-Command -Module $ModuleName -Name Get-PSPuTTYTheme).Count | Should be 1
        }

        it 'Should have a Merge-PSPuTTYTheme command' {
            (Get-Command -Module $ModuleName -Name Merge-PSPuTTYTheme).Count | Should be 1
        }

        it 'Should have a Invoke-PSPuTTYSession command' {
            (Get-Command -Module $ModuleName -Name Invoke-PSPuTTYSession).Count | Should be 1
        }

        it 'Should have a New-PSPuTTYSession command' {
            (Get-Command -Module $ModuleName -Name New-PSPuTTYSession).Count | Should be 1
        }

        it 'Should have a Remove-PSPuTTYSession command' {
            (Get-Command -Module $ModuleName -Name Remove-PSPuTTYSession).Count | Should be 1
        }
    }

    context -Name 'Get-PSPuTTYTheme' {
        it 'Should not throw an error' {
            { Get-PSPuTTYTheme } | Should not throw
        }
    }

    context -Name 'Get-PSPuTTYSession' {
        it 'Should not throw an error' {
            { Get-PSPuTTYSession } | Should not throw
        }
    }

    context -Name 'Merge-PSPuTTYTheme' {
        it 'Should have four parameter sets' {
            (Get-Command -Module $ModuleName -Name Merge-PSPuTTYTheme).ParameterSets.Count | Should be 4
        }
    }

    context -Name 'Remove-PSPuTTYSession' -Fixture {
        it 'Should require input parameters' {
            ${gps} | Should throw
        }
    }
}