2626 InModuleScope $script :DSCResourceName {
2727 $script :DSCResourceName = ' MSFT_xOfflineDomainJoin'
2828
29- $TestOfflineDomainJoin = @ {
29+ $testOfflineDomainJoin = @ {
3030 IsSingleInstance = ' Yes'
3131 RequestFile = ' C:\ODJRequest.txt'
32- Verbose = $True
32+ Verbose = $true
3333 }
3434
3535 Describe " $ ( $script :DSCResourceName ) \Get-TargetResource" {
3636 It ' Should return the correct values' {
37- $Result = Get-TargetResource `
37+ $result = Get-TargetResource `
3838 @TestOfflineDomainJoin
3939
40- $Result .IsSingleInstance | Should Be $TestOfflineDomainJoin .IsSingleInstance
41- $Result .RequestFile | Should Be ' '
40+ $result .IsSingleInstance | Should Be $testOfflineDomainJoin .IsSingleInstance
41+ $result .RequestFile | Should Be ' '
4242 }
4343 }
4444
4545 Describe " $ ( $script :DSCResourceName ) \Set-TargetResource" {
4646 Context ' Domain is not joined' {
47- Mock - CommandName Test-Path - MockWith { return $True }
47+ Mock - CommandName Test-Path - MockWith {
48+ return $true
49+ }
50+
4851 Mock - CommandName Join-Domain
4952
5053 It ' Should not throw exception' {
5861 }
5962
6063 Context ' ODJ Request file is not found' {
61- Mock - CommandName Test-Path - MockWith { return $False }
64+ Mock - CommandName Test-Path - MockWith {
65+ return $false
66+ }
67+
6268 Mock - CommandName Join-Domain
6369
6470 It ' Should throw expected exception' {
6571 $errorRecord = Get-InvalidArgumentRecord `
66- - Message ($LocalizedData.RequestFileNotFoundError -f $TestOfflineDomainJoin .RequestFile ) `
72+ - Message ($LocalizedData.RequestFileNotFoundError -f $testOfflineDomainJoin .RequestFile ) `
6773 - ArgumentName ' RequestFile'
6874
6975 { Test-TargetResource @TestOfflineDomainJoin } | Should Throw $errorRecord
7884
7985 Describe " $ ( $script :DSCResourceName ) \Test-TargetResource" {
8086 Context ' Domain is not joined' {
81- Mock - CommandName Test-Path - MockWith { return $True }
82- Mock - CommandName Get-DomainName - MockWith { return $null }
87+ Mock - CommandName Test-Path - MockWith {
88+ return $true
89+ }
90+
91+ Mock - CommandName Get-DomainName - MockWith {
92+ return $null
93+ }
8394
8495 It ' Should return false' {
8596 Test-TargetResource @TestOfflineDomainJoin | should be $false
92103 }
93104
94105 Context ' Domain is already joined' {
95- Mock - CommandName Test-Path - MockWith { return $True }
96- Mock - CommandName Get-DomainName - MockWith { return ' contoso.com' }
106+ Mock - CommandName Test-Path - MockWith {
107+ return $true
108+ }
109+
110+ Mock - CommandName Get-DomainName - MockWith {
111+ return ' contoso.com'
112+ }
97113
98114 It ' Should return false' {
99115 Test-TargetResource @TestOfflineDomainJoin | should be $true
@@ -106,12 +122,17 @@ try
106122 }
107123
108124 Context ' ODJ Request file is not found' {
109- Mock - CommandName Test-Path - MockWith { return $False }
110- Mock - CommandName Get-DomainName - MockWith { return ' contoso.com' }
125+ Mock - CommandName Test-Path - MockWith {
126+ return $false
127+ }
128+
129+ Mock - CommandName Get-DomainName - MockWith {
130+ return ' contoso.com'
131+ }
111132
112133 It ' Should throw expected exception' {
113134 $errorRecord = Get-InvalidArgumentRecord `
114- - Message ($LocalizedData.RequestFileNotFoundError -f $TestOfflineDomainJoin .RequestFile ) `
135+ - Message ($LocalizedData.RequestFileNotFoundError -f $testOfflineDomainJoin .RequestFile ) `
115136 - ArgumentName ' RequestFile'
116137
117138 { Test-TargetResource @TestOfflineDomainJoin } | Should Throw $errorRecord
126147
127148 Describe " $ ( $script :DSCResourceName ) \Join-Domain" {
128149 Context ' Domain Join successful' {
129- Mock - CommandName djoin.exe - MockWith { $script :LASTEXITCODE = 0 ; return " OK" }
150+ Mock - CommandName djoin.exe - MockWith {
151+ $script :LASTEXITCODE = 0
152+ return " OK"
153+ }
130154
131155 It ' Should not throw' {
132156 { Join-Domain - RequestFile ' c:\doesnotmatter.txt' } | Should Not Throw
138162 }
139163
140164 Context ' Domain Join successful' {
141- Mock - CommandName djoin.exe - MockWith { $script :LASTEXITCODE = 99 ; return " ERROR" }
165+ Mock - CommandName djoin.exe - MockWith {
166+ $script :LASTEXITCODE = 99
167+ return " ERROR"
168+ }
142169
143170 $errorRecord = Get-InvalidOperationRecord `
144171 - Message $ ($LocalizedData.DjoinError -f 99 )
0 commit comments