Skip to content

Commit

Permalink
adjusting the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
SSvilen committed Apr 20, 2020
1 parent d4b05ec commit 49ee713
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions tests/Unit/MSFT_xExchAddressList.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,13 @@ try
}

Describe 'MSFT_xExchAddressList.tests\Set-TargetResource' -Tag 'Set' {
BeforeAll {
Mock -CommandName Write-FunctionEntry -Verifiable
Mock -CommandName Get-RemoteExchangeSession -Verifiable
}
Mock -CommandName Write-FunctionEntry -Verifiable
Mock -CommandName Get-RemoteExchangeSession -Verifiable

AfterEach {
Assert-VerifiableMock
}

Context 'Customized filters and precanned filters are used simultaneously' {
It 'Should throw' {
$setTargetResourceParams = @{
Name = 'MyCustomAddressList'
Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'fakeuser', (New-Object -TypeName System.Security.SecureString)
RecipientFilter = "(RecipientType -eq 'UserMailbox')"
IncludedRecipients = 'MailUsers'
}

{ Set-TargetResource @setTargetResourceParams } | Should -Throw
}
}

Context 'Address list is present' {
Mock -CommandName 'Get-TargetResource' -MockWith {
return @{
Expand Down Expand Up @@ -203,6 +188,27 @@ try
}
}

Describe 'MSFT_xExchAddressList.tests\Set-TargetResource - wrong filters' -Tag 'Set' {
Context 'Customized filters and precanned filters are used simultaneously' {
Mock -CommandName Write-FunctionEntry -Verifiable

It 'Should throw' {
$setTargetResourceParams = @{
Name = 'MyCustomAddressList'
Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'fakeuser', (New-Object -TypeName System.Security.SecureString)
RecipientFilter = "(RecipientType -eq 'UserMailbox')"
IncludedRecipients = 'MailUsers'
}

Mock -CommandName Get-RemoteExchangeSession

{ Set-TargetResource @setTargetResourceParams } | Should -Throw
}

Assert-VerifiableMock
}
}

Describe 'MSFT_xExchAddressList.tests\Test-TargetResource' -Tag 'Test' {
BeforeAll {
Mock -CommandName Write-FunctionEntry -Verifiable
Expand Down

0 comments on commit 49ee713

Please sign in to comment.