-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathNew-MgGroup.Tests.ps1
51 lines (46 loc) · 2.03 KB
/
New-MgGroup.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
BeforeAll {
if (($null -eq $TestName) -or ($TestName -contains 'New-MgGroup')) {
# Set test mode to playback.
$TestMode = 'playback'
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
if (-Not (Test-Path -Path $loadEnvPath)) {
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
}
. ($loadEnvPath)
$TestRecordingFile = Join-Path $PSScriptRoot 'New-MgGroup.Recording.json'
$currentPath = $PSScriptRoot
while (-not $mockingPath) {
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
$currentPath = Split-Path -Path $currentPath -Parent
}
. ($mockingPath | Select-Object -First 1).FullName
}
}
Describe 'New-MgGroup' {
BeforeAll {
$Mock.PushDescription('New-MgGroup')
}
Context 'Create' {
It 'ShouldCreateNewGroup' {
$CreateGroups = @()
1..100 | ForEach-Object {
$Mock.PushScenario('ShouldCreateNewGroup')
$CreateGroups += New-MgGroup -DisplayName "new-mggroup-test" -MailEnabled:$false -MailNickname 'unused' -SecurityEnabled
}
$CreateGroups | Should -HaveCount 100
$CreateGroups[0].DisplayName | Should -Be "new-mggroup-test"
$CreateGroups[0].MailEnabled | Should -BeFalse
}
It 'ShouldHaveASingleResponseObjectIfRHVIsPassed' {
$Mock.PushScenario('ShouldCreateNewGroup')
$group = New-MgGroup -DisplayName "new-mggroup-test" -MailEnabled:$false -MailNickname 'unused' -SecurityEnabled -RHV rh
$group.Count | Should -HaveCount 1
}
It 'ShouldAssignRetrieveHeadersToRHVIfPassed' {
$Mock.PushScenario('ShouldCreateNewGroup')
New-MgGroup -DisplayName "new-mggroup-test" -MailEnabled:$false -MailNickname 'unused' -SecurityEnabled -RHV rv
$rv.Vary | Should -Be "Accept-Encoding"
$rv.'Content-Type' | Should -Be "application/json"
}
}
}