From 49ee713a3138d45b45d33843d2d57628e12a61f4 Mon Sep 17 00:00:00 2001 From: Svilen Sultanov Date: Mon, 20 Apr 2020 21:37:36 +0200 Subject: [PATCH] adjusting the unit test --- tests/Unit/MSFT_xExchAddressList.tests.ps1 | 40 +++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/tests/Unit/MSFT_xExchAddressList.tests.ps1 b/tests/Unit/MSFT_xExchAddressList.tests.ps1 index f61d6734..b78e01bf 100644 --- a/tests/Unit/MSFT_xExchAddressList.tests.ps1 +++ b/tests/Unit/MSFT_xExchAddressList.tests.ps1 @@ -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 @{ @@ -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