@@ -82,6 +82,12 @@ InModuleScope MSFT_xComputer {
8282 Mock GetComputerDomain {' contoso.com' }
8383 Test-TargetResource - Name $Env: ComputerName - WorkGroupName ' Contoso' - Credential $Credential - UnjoinCredential $Credential | Should Be $false
8484 }
85+ It ' Throws if name is to long' {
86+ {Test-TargetResource - Name " ThisNameIsTooLong" } | Should Throw
87+ }
88+ It ' Throws if name contains illigal characters' {
89+ {Test-TargetResource - Name " ThisIsBad<>" } | Should Throw
90+ }
8591
8692 }
8793 Context Get-TargetResource {
@@ -93,6 +99,12 @@ InModuleScope MSFT_xComputer {
9399 $Result.GetType ().Fullname | Should Be ' System.Collections.Hashtable'
94100 $Result.Keys | Should Be @ (' Name' , ' DomainName' , ' JoinOU' , ' CurrentOU' , ' Credential' , ' UnjoinCredential' , ' WorkGroupName' )
95101 }
102+ It ' Throws if name is to long' {
103+ {Get-TargetResource - Name " ThisNameIsTooLong" } | Should Throw
104+ }
105+ It ' Throws if name contains illigal characters' {
106+ {Get-TargetResource - Name " ThisIsBad<>" } | Should Throw
107+ }
96108 }
97109 Context Set-TargetResource {
98110 Mock Rename-Computer {}
@@ -196,6 +208,12 @@ InModuleScope MSFT_xComputer {
196208 Assert-MockCalled - CommandName Rename-Computer - Exactly 1 - Scope It
197209 Assert-MockCalled - CommandName Add-Computer - Exactly 0 - Scope It
198210 }
211+ It ' Throws if name is to long' {
212+ {Set-TargetResource - Name " ThisNameIsTooLong" } | Should Throw
213+ }
214+ It ' Throws if name contains illigal characters' {
215+ {Set-TargetResource - Name " ThisIsBad<>" } | Should Throw
216+ }
199217 }
200218 }
201219}
0 commit comments