@@ -28,7 +28,7 @@ BeforeAll {
2828
2929 $env: SqlServerDscCI = $true
3030
31- Import-Module - Name $script :dscModuleName
31+ Import-Module - Name $script :dscModuleName - Force
3232
3333 # Loading mocked classes
3434 Add-Type - Path (Join-Path - Path (Join-Path - Path $PSScriptRoot - ChildPath ' ../Stubs' ) - ChildPath ' SMO.cs' )
@@ -244,14 +244,16 @@ Describe 'Get-SqlDscServerPermission' -Tag 'Public' {
244244 }
245245 }
246246
247- It ' Should call Test-SqlDscIsLogin but not Test-SqlDscIsRole when login is found ' {
247+ It ' Should call both Test-SqlDscIsLogin and Test-SqlDscIsRole' {
248248 $null = Get-SqlDscServerPermission - ServerObject $mockServerObject - Name ' TestPrincipal' - ErrorAction ' SilentlyContinue'
249249
250250 Should - Invoke - CommandName Test-SqlDscIsLogin - ParameterFilter {
251251 $ServerObject.Equals ($mockServerObject ) -and $Name -eq ' TestPrincipal'
252252 } - Exactly - Times 1
253253
254- Should - Invoke - CommandName Test-SqlDscIsRole - Exactly - Times 0
254+ Should - Invoke - CommandName Test-SqlDscIsRole - ParameterFilter {
255+ $ServerObject.Equals ($mockServerObject ) -and $Name -eq ' TestPrincipal'
256+ } - Exactly - Times 1
255257 }
256258 }
257259
@@ -266,7 +268,7 @@ Describe 'Get-SqlDscServerPermission' -Tag 'Public' {
266268 }
267269 }
268270
269- It ' Should call both Test-SqlDscIsLogin and Test-SqlDscIsRole when login is not found ' {
271+ It ' Should call both Test-SqlDscIsLogin and Test-SqlDscIsRole' {
270272 $null = Get-SqlDscServerPermission - ServerObject $mockServerObject - Name ' TestPrincipal' - ErrorAction ' SilentlyContinue'
271273
272274 Should - Invoke - CommandName Test-SqlDscIsLogin - ParameterFilter {
@@ -334,14 +336,16 @@ Describe 'Get-SqlDscServerPermission' -Tag 'Public' {
334336 }
335337 }
336338
337- It ' Should call Test-SqlDscIsLogin but not Test-SqlDscIsRole when login is found ' {
339+ It ' Should call both Test-SqlDscIsLogin and Test-SqlDscIsRole when both types are specified ' {
338340 $null = Get-SqlDscServerPermission - ServerObject $mockServerObject - Name ' TestPrincipal' - PrincipalType ' Login' , ' Role' - ErrorAction ' SilentlyContinue'
339341
340342 Should - Invoke - CommandName Test-SqlDscIsLogin - ParameterFilter {
341343 $ServerObject.Equals ($mockServerObject ) -and $Name -eq ' TestPrincipal'
342344 } - Exactly - Times 1
343345
344- Should - Invoke - CommandName Test-SqlDscIsRole - Exactly - Times 0
346+ Should - Invoke - CommandName Test-SqlDscIsRole - ParameterFilter {
347+ $ServerObject.Equals ($mockServerObject ) -and $Name -eq ' TestPrincipal'
348+ } - Exactly - Times 1
345349 }
346350 }
347351 }
0 commit comments