|
104 | 104 | )
|
105 | 105 | }
|
106 | 106 |
|
| 107 | + $mockNewObjectWindowsIdentity = { |
| 108 | + return [PSCustomObject] @{} | |
| 109 | + Add-Member -MemberType ScriptMethod -Name Impersonate -Value { |
| 110 | + return [PSCustomObject] @{} | |
| 111 | + Add-Member -MemberType ScriptMethod -Name Undo -Value {} -PassThru | |
| 112 | + Add-Member -MemberType ScriptMethod -Name Dispose -Value {} -PassThru -Force |
| 113 | + } -PassThru -Force |
| 114 | + } |
| 115 | + |
| 116 | + $mockNewObjectWindowsIdentity_ParameterFilter = { |
| 117 | + $TypeName -eq 'Security.Principal.WindowsIdentity' |
| 118 | + } |
| 119 | + |
107 | 120 | $mockDefaultParameters = @{
|
108 | 121 | Name = $mockClusterName
|
109 | 122 | StaticIPAddress = $mockStaticIpAddress
|
|
140 | 153 | Mock -CommandName Add-Type -MockWith {
|
141 | 154 | return $mockLibImpersonationObject
|
142 | 155 | }
|
| 156 | + |
| 157 | + Mock -CommandName New-Object -MockWith $mockNewObjectWindowsIdentity -ParameterFilter $mockNewObjectWindowsIdentity_ParameterFilter -Verifiable |
143 | 158 | }
|
144 | 159 |
|
145 | 160 | Context 'When the computers domain name cannot be evaluated' {
|
|
194 | 209 | }
|
195 | 210 |
|
196 | 211 | Describe 'xCluster\Set-TargetResource' {
|
| 212 | + BeforeAll { |
| 213 | + Mock -CommandName Add-Type -MockWith { |
| 214 | + return $mockLibImpersonationObject |
| 215 | + } |
| 216 | + |
| 217 | + Mock -CommandName New-Object -MockWith $mockNewObjectWindowsIdentity -ParameterFilter $mockNewObjectWindowsIdentity_ParameterFilter -Verifiable |
| 218 | + } |
| 219 | + |
197 | 220 | Context 'When computers domain name cannot be evaluated' {
|
198 | 221 | It 'Should throw the correct error message' {
|
199 | 222 | $mockDynamicDomainName = $null
|
|
339 | 362 | }
|
340 | 363 |
|
341 | 364 | Describe 'xCluster\Test-TargetResource' {
|
| 365 | + BeforeAll { |
| 366 | + Mock -CommandName Add-Type -MockWith { |
| 367 | + return $mockLibImpersonationObject |
| 368 | + } |
| 369 | + |
| 370 | + Mock -CommandName New-Object -MockWith $mockNewObjectWindowsIdentity -ParameterFilter $mockNewObjectWindowsIdentity_ParameterFilter -Verifiable |
| 371 | + } |
| 372 | + |
342 | 373 | Context 'When computers domain name cannot be evaluated' {
|
343 | 374 | It 'Should throw the correct error message' {
|
344 | 375 | $mockDynamicDomainName = $null
|
|
0 commit comments