Skip to content

Commit e0a0e89

Browse files
author
Yannick Beot - ADM
committed
Add tests
1 parent 9a2f31b commit e0a0e89

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Tests/Unit/MSFT_Computer.Tests.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,31 @@ try
613613
Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter { $WorkGroupName }
614614
}
615615

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+
616641
It 'Changes ComputerName and changes Workgroup to Domain with specified OU' {
617642
Mock -CommandName Get-WMIObject -MockWith {
618643
[PSCustomObject] @{
@@ -1008,6 +1033,12 @@ try
10081033
Assert-MockCalled -CommandName Get-Item -Exactly -Times 0 -Scope It
10091034
}
10101035
}
1036+
1037+
Context "$($script:DSCResourceName)\Get-LogonServer" {
1038+
It 'Should return a non-empty string' {
1039+
Get-LogonServer | Should -Not -BeNullOrEmpty
1040+
}
1041+
}
10111042
}
10121043
} #end InModuleScope $DSCResourceName
10131044
#endregion

0 commit comments

Comments
 (0)