@@ -121,16 +121,25 @@ try
121121 It ' Should not Throw if name is localhost' {
122122 {Test-TargetResource - Name " localhost" } | Should Not Throw
123123 }
124-
124+ It ' Should return true if description is same as specified' {
125+ Mock Get-CimInstance {[PSCustomObject ]@ {Description = ' This is my computer' }}
126+ Test-TargetResource - Name $env: COMPUTERNAME - Description " This is my computer" | Should Be $true
127+ Test-TargetResource - Name ' localhost' - Description " This is my computer" | Should Be $true
128+ }
129+ It ' Should return false if description is same as specified' {
130+ Mock Get-CimInstance {[PSCustomObject ]@ {Description = ' This is not my computer' }}
131+ Test-TargetResource - Name $env: COMPUTERNAME - Description " This is my computer" | Should Be $true
132+ Test-TargetResource - Name ' localhost' - Description " This is my computer" | Should Be $true
133+ }
125134 }
126135 Context " $ ( $Global :DSCResourceName ) \Get-TargetResource" {
127136 It ' should not throw' {
128137 {Get-TargetResource - Name $env: COMPUTERNAME } | Should Not Throw
129138 }
130- It ' Should return a hashtable containing Name, DomainName, JoinOU, CurrentOU, Credential, UnjoinCredential and WorkGroupName ' {
139+ It ' Should return a hashtable containing Name, DomainName, JoinOU, CurrentOU, Credential, UnjoinCredential, WorkGroupName and Description ' {
131140 $Result = Get-TargetResource - Name $env: COMPUTERNAME
132141 $Result.GetType ().Fullname | Should Be ' System.Collections.Hashtable'
133- $Result.Keys | Sort-Object | Should Be @ (' Credential' , ' CurrentOU' , ' DomainName' , ' JoinOU' , ' Name' , ' UnjoinCredential' , ' WorkGroupName' )
142+ $Result.Keys | Sort-Object | Should Be @ (' Credential' , ' CurrentOU' , ' DomainName' , ' JoinOU' , ' Name' , ' UnjoinCredential' , ' WorkGroupName' , ' Description ' )
134143 }
135144 It ' Throws if name is to long' {
136145 {Get-TargetResource - Name " ThisNameIsTooLong" } | Should Throw
274283 It ' Throws if name contains illigal characters' {
275284 {Set-TargetResource - Name " ThisIsBad<>" } | Should Throw
276285 }
286+ It ' Changes computer description' {
287+ Mock Get-CimInstance {[PSCustomObject ]@ {Description = ' This is not my computer' }}
288+ Set-TargetResource - Name $env: COMPUTERNAME - Description = ' This is my computer'
289+ Assert-MockCalled - CommandName Set-CimInstance - Exactly 1 - Scope It
290+ }
277291 }
278292 }
279293 } # end InModuleScope $DSCResourceName
0 commit comments