tests/unit/functions/Test-AWPInstall.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
InModuleScope awp {
    Describe 'Test-AWPInstall' {
        Mock New-PSSession { }

        Context 'General Tests' {
            Mock Invoke-Command {
                @{
                    UninstallString  = '{23478236378hjdfgsdfg78dftsd}'
                    DisplayVersion = '6.76.5'
                }
            }

            It 'Parameter Tests' {
                { Test-AWPInstall } | Should Not Throw
                { Test-AWPInstall -cred } | Should throw
            }
        }
        Context 'AWP Agent Installed' {
            Mock Invoke-Command {
                @{
                    UninstallString = '/x {23478236378hjdfgsdfg78dftsd}'
                    DisplayVersion = '6.76.5'
                }
            }

            It 'Un-Install string and DisplayVersion exists' { 
            (Test-AWPInstall).isInstalled | Should Be $true
            }
        }

        Context 'AWP Agent Not Installed' { 
            Mock Invoke-Command { }

            It 'Un-Install string and DisplayVersion does not exists' { 
            (Test-AWPInstall).isInstalled | Should Be $false
            }
        }
    }
}