-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest-M1.Tests.ps1
More file actions
49 lines (45 loc) · 1.19 KB
/
Test-M1.Tests.ps1
File metadata and controls
49 lines (45 loc) · 1.19 KB
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
BeforeAll {
& $PSScriptRoot\..\..\..\Modules\Import-M1.ps1
. $PSScriptRoot\..\..\Cmdlets-Helpers\Get-RandomValue.ps1
}
Describe -Tag @("M1","Module","InModuleScope") "InModuleScope M1" {
It "Get-M1Private" {
InModuleScope M1 {
Get-M1Private| Should -BeExactly "M1 Private"
}
}
It "Get-M1" {
Get-M1| Should -BeExactly "M1"
}
}
Describe -Tag @("M1","Module","InModuleScope","MockPrivate") "InModuleScope M1 Mock private" {
BeforeEach {
$mockedValue=Get-RandomValue -String
Mock -ModuleName M1 Get-M1Private {
$mockedValue
}
$inModuleScopeParameters = @{
mockedValue = $mockedValue
}
}
It "Get-M1Private Mocked" {
InModuleScope M1 -Parameters $inModuleScopeParameters {
param($mockedValue)
Get-M1Private| Should -BeExactly $mockedValue
}
}
It "Get-M1" {
Get-M1| Should -BeExactly $mockedValue
}
}
Describe -Tag @("M1","Module") "M1" {
It "Get-M1Private throws" {
{Get-M1Private} | Should -Throw
}
It "Get-M1" {
Get-M1| Should -BeExactly "M1"
}
}
AfterAll {
Remove-Module -Name M1 -Force
}