tests/New-AzureVPNRootCertificate.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
if(-not (Get-Module azureVpnP2SSelfSignedCertificate)) {
  $here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace('tests', '')
  Import-Module (Join-Path $here 'azureVpnP2SSelfSignedCertificate.psd1') 
}

InModuleScope -moduleName azureVpnP2SSelfSignedCertificate {
    Describe 'New-AzureVPNRootCertificate' {
        BeforeAll {
            Mock New-SelfSignedCertificate {}
        }

        Context 'Logic' {
            it 'Parameters' {
                {New-AzureVPNRootCertificate -subject 'azureSubject' -ErrorAction Stop} | Should Not Throw
            }

            it 'Create Self-Signed root certificate' {
                New-AzureVPNRootCertificate -subject 'azureSubject' -ErrorAction SilentlyContinue | Out-Null

                Assert-MockCalled New-SelfSignedCertificate -Exactly 1 -Scope It
            }
        }
    }
}