You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tests/Unit/MSFT_Computer.Tests.ps1
+33-2Lines changed: 33 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ try
96
96
}
97
97
98
98
It 'Should return True if Workgroup name is same as specified' {
99
-
Mock -CommandName Get-WMIObject-MockWith {
99
+
Mock -CommandName Get-CimInstance-MockWith {
100
100
[PSCustomObject] @{
101
101
Domain='Workgroup';
102
102
Workgroup='Workgroup';
@@ -457,7 +457,7 @@ try
457
457
-Verbose
458
458
459
459
$Result.GetType().Fullname | Should -Be 'System.Collections.Hashtable'
460
-
$Result.Keys|Sort-Object| Should -Be @('Credential','CurrentOU','Description','DomainName','JoinOU','Name','UnjoinCredential','WorkGroupName')
460
+
$Result.Keys|Sort-Object| Should -Be @('Credential','CurrentOU','Description','DomainName','JoinOU','Name','Server','UnjoinCredential','WorkGroupName')
461
461
}
462
462
463
463
It 'Throws if name is to long' {
@@ -613,6 +613,31 @@ try
613
613
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 0-Scope It -ParameterFilter { $WorkGroupName }
614
614
}
615
615
616
+
It 'Changes ComputerName and changes Workgroup to Domain with specified Domain Controller' {
617
+
Mock -CommandName Get-WMIObject-MockWith {
618
+
[PSCustomObject] @{
619
+
Domain='Contoso';
620
+
Workgroup='Contoso';
621
+
PartOfDomain=$false
622
+
}
623
+
}
624
+
625
+
Mock -CommandName Get-ComputerDomain-MockWith {
626
+
''
627
+
}
628
+
629
+
Set-TargetResource`
630
+
-Name $notComputerName`
631
+
-DomainName 'Contoso.com'`
632
+
-Server 'dc01.contoso.com'`
633
+
-Credential $credential`
634
+
-Verbose | Should -BeNullOrEmpty
635
+
636
+
Assert-MockCalled-CommandName Rename-Computer-Exactly -Times 0-Scope It
637
+
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 1-Scope It -ParameterFilter { $DomainName-and$NewName-and$Server }
638
+
Assert-MockCalled-CommandName Add-Computer-Exactly -Times 0-Scope It -ParameterFilter { $WorkGroupName }
639
+
}
640
+
616
641
It 'Changes ComputerName and changes Workgroup to Domain with specified OU' {
617
642
Mock -CommandName Get-WMIObject-MockWith {
618
643
[PSCustomObject] @{
@@ -1008,6 +1033,12 @@ try
1008
1033
Assert-MockCalled-CommandName Get-Item-Exactly -Times 0-Scope It
0 commit comments