@@ -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' , ' 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 {}
@@ -171,6 +183,12 @@ InModuleScope MSFT_xComputer {
171183 Assert-MockCalled - CommandName Rename-Computer - Exactly 1 - Scope It
172184 Assert-MockCalled - CommandName Add-Computer - Exactly 0 - Scope It
173185 }
186+ It ' Throws if name is to long' {
187+ {Set-TargetResource - Name " ThisNameIsTooLong" } | Should Throw
188+ }
189+ It ' Throws if name contains illigal characters' {
190+ {Set-TargetResource - Name " ThisIsBad<>" } | Should Throw
191+ }
174192 }
175193 }
176194}
0 commit comments