Skip to content

Commit a3525e9

Browse files
committed
Additional Formatting Fixes
1 parent 1c5d787 commit a3525e9

1 file changed

Lines changed: 52 additions & 18 deletions

File tree

Tests/Unit/MSFT_xComputer.Tests.ps1

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ try
3131
$SecPassword = New-Object -Type SecureString
3232
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'USER', $SecPassword
3333
$NotComputerName = if ($env:COMPUTERNAME -ne 'othername')
34-
{'othername'
34+
{
35+
'othername'
3536
}
3637
else
37-
{'name'
38+
{
39+
'name'
3840
}
3941

4042
Context "$($Global:DSCResourceName)\Test-TargetResource" {
@@ -59,7 +61,9 @@ try
5961
PartOfDomain = $true
6062
}
6163
}
62-
Mock -CommandName Get-ComputerDomain -MockWith {'contoso.com'}
64+
Mock -CommandName Get-ComputerDomain -MockWith {
65+
'contoso.com'
66+
}
6367
Test-TargetResource -Name $Env:ComputerName -DomainName 'Contoso.com' -Credential $Credential | Should Be $true
6468
}
6569
It 'Should return True if Workgroup name is same as specified' {
@@ -70,7 +74,9 @@ try
7074
PartOfDomain = $false
7175
}
7276
}
73-
Mock -CommandName Get-ComputerDomain -MockWith {''}
77+
Mock -CommandName Get-ComputerDomain -MockWith {
78+
''
79+
}
7480
Test-TargetResource -Name $Env:ComputerName -WorkGroupName 'workgroup' | Should Be $true
7581
}
7682
It 'Should return True if ComputerName and Domain name is same as specified' {
@@ -95,7 +101,9 @@ try
95101
PartOfDomain = $false
96102
}
97103
}
98-
Mock -CommandName Get-ComputerDomain -MockWith {''}
104+
Mock -CommandName Get-ComputerDomain -MockWith {
105+
''
106+
}
99107
Test-TargetResource -Name $Env:ComputerName -WorkGroupName 'workgroup' | Should Be $true
100108
Test-TargetResource -Name 'localhost' -WorkGroupName 'workgroup' | Should Be $true
101109
}
@@ -107,7 +115,9 @@ try
107115
PartOfDomain = $false
108116
}
109117
}
110-
Mock -CommandName Get-ComputerDomain -MockWith {''}
118+
Mock -CommandName Get-ComputerDomain -MockWith {
119+
''
120+
}
111121
Test-TargetResource -Name $Env:ComputerName | Should Be $true
112122
Test-TargetResource -Name 'localhost' | Should Be $true
113123
Mock -CommandName Get-WmiObject {
@@ -131,7 +141,9 @@ try
131141
PartOfDomain = $false
132142
}
133143
}
134-
Mock -CommandName Get-ComputerDomain -MockWith {''}
144+
Mock -CommandName Get-ComputerDomain -MockWith {
145+
''
146+
}
135147
Test-TargetResource -Name $NotComputerName | Should Be $false
136148
Mock -CommandName Get-WmiObject -MockWith {
137149
[PSCustomObject] @{
@@ -140,7 +152,9 @@ try
140152
PartOfDomain = $true
141153
}
142154
}
143-
Mock -CommandName Get-ComputerDomain -MockWith {'contoso.com'}
155+
Mock -CommandName Get-ComputerDomain -MockWith {
156+
'contoso.com'
157+
}
144158
Test-TargetResource -Name $NotComputerName | Should Be $false
145159
}
146160
It 'Should return False if Domain name is not same as specified' {
@@ -165,7 +179,9 @@ try
165179
PartOfDomain = $false
166180
}
167181
}
168-
Mock -CommandName Get-ComputerDomain -MockWith {''}
182+
Mock -CommandName Get-ComputerDomain -MockWith {
183+
''
184+
}
169185
Test-TargetResource -Name $Env:ComputerName -WorkGroupName 'NOTworkgroup' | Should Be $false
170186
Test-TargetResource -Name 'localhost' -WorkGroupName 'NOTworkgroup' | Should Be $false
171187
}
@@ -177,7 +193,9 @@ try
177193
PartOfDomain = $false
178194
}
179195
}
180-
Mock -CommandName Get-ComputerDomain -MockWith {''}
196+
Mock -CommandName Get-ComputerDomain -MockWith {
197+
''
198+
}
181199
Test-TargetResource -Name $NotComputerName -WorkGroupName 'workgroup' | Should Be $false
182200
Mock -CommandName Get-WMIObject -MockWith {
183201
[PSCustomObject] @{
@@ -199,7 +217,9 @@ try
199217
PartOfDomain = $false
200218
}
201219
}
202-
Mock -CommandName Get-ComputerDomain -MockWith {''}
220+
Mock -CommandName Get-ComputerDomain -MockWith {
221+
''
222+
}
203223
Test-TargetResource -Name $Env:ComputerName -DomainName 'contoso.com' -Credential $Credential | Should Be $false
204224
Test-TargetResource -Name 'localhost' -DomainName 'contoso.com' -Credential $Credential | Should Be $false
205225
}
@@ -331,7 +351,9 @@ try
331351
PartOfDomain = $false
332352
}
333353
}
334-
Mock -CommandName Get-ComputerDomain -MockWith {''}
354+
Mock -CommandName Get-ComputerDomain -MockWith {
355+
''
356+
}
335357
Set-TargetResource -Name $NotComputerName -DomainName 'Contoso.com' -Credential $Credential | Should BeNullOrEmpty
336358
Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It
337359
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter {$DomainName -and $NewName}
@@ -345,7 +367,9 @@ try
345367
PartOfDomain = $false
346368
}
347369
}
348-
Mock -CommandName Get-ComputerDomain -MockWith {''}
370+
Mock -CommandName Get-ComputerDomain -MockWith {
371+
''
372+
}
349373
Set-TargetResource -Name $NotComputerName -DomainName 'Contoso.com' -JoinOU 'OU=Computers,DC=contoso,DC=com' -Credential $Credential | Should BeNullOrEmpty
350374
Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It
351375
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter {$DomainName -and $NewName}
@@ -359,7 +383,9 @@ try
359383
PartOfDomain = $false
360384
}
361385
}
362-
Mock -CommandName Get-ComputerDomain -MockWith {''}
386+
Mock -CommandName Get-ComputerDomain -MockWith {
387+
''
388+
}
363389
Set-TargetResource -Name $NotComputerName -WorkGroupName 'adventure-works' | Should BeNullOrEmpty
364390
Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It
365391
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter {$WorkGroupName -and $NewName}
@@ -441,7 +467,9 @@ try
441467
PartOfDomain = $true
442468
}
443469
}
444-
Mock -CommandName Get-ComputerDomain -MockWith {''}
470+
Mock -CommandName Get-ComputerDomain -MockWith {
471+
''
472+
}
445473
Set-TargetResource -Name $Env:ComputerName -WorkGroupName 'Contoso' -UnjoinCredential $Credential | Should BeNullOrEmpty
446474
Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It
447475
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter {$NewName}
@@ -456,7 +484,9 @@ try
456484
PartOfDomain = $true
457485
}
458486
}
459-
Mock -CommandName Get-ComputerDomain -MockWith {''}
487+
Mock -CommandName Get-ComputerDomain -MockWith {
488+
''
489+
}
460490
Set-TargetResource -Name 'localhost' -WorkGroupName 'Contoso' -UnjoinCredential $Credential | Should BeNullOrEmpty
461491
Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It
462492
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter {$NewName}
@@ -479,7 +509,9 @@ try
479509
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It
480510
}
481511
It 'Changes only ComputerName in Workgroup' {
482-
Mock -CommandName Get-ComputerDomain -MockWith {''}
512+
Mock -CommandName Get-ComputerDomain -MockWith {
513+
''
514+
}
483515
Mock -CommandName Get-WMIObject -MockWith {
484516
[PSCustomObject] @{
485517
Domain = 'Contoso';
@@ -498,7 +530,9 @@ try
498530
{Set-TargetResource -Name "ThisIsBad<>"} | Should Throw
499531
}
500532
It 'Changes computer description in a workgroup' {
501-
Mock -CommandName Get-ComputerDomain -MockWith {''}
533+
Mock -CommandName Get-ComputerDomain -MockWith {
534+
''
535+
}
502536
Mock -CommandName Get-WMIObject {
503537
[PSCustomObject] @{
504538
Domain = 'Contoso';

0 commit comments

Comments
 (0)