1- Remove-Module - Name BOSH.Account - ErrorAction Ignore
2- Import-Module ./ BOSH.Account.psm1
1+ BeforeAll {
2+ Remove-Module - Name BOSH.Account - ErrorAction Ignore
3+ Import-Module ./ BOSH.Account.psm1
34
4- Remove-Module - Name BOSH.Utils - ErrorAction Ignore
5- Import-Module ../ BOSH.Utils/ BOSH.Utils.psm1
5+ Remove-Module - Name BOSH.Utils - ErrorAction Ignore
6+ Import-Module ../ BOSH.Utils/ BOSH.Utils.psm1
7+ }
68
79Describe " Account" {
8-
910 Context " when username is not provided" {
1011 It " throws" {
11- { Add-Account } | Should Throw " Provide a user name"
12+ { Add-Account } | Should - Throw " Provide a user name"
1213 }
1314 }
1415
1516 Context " when password is not provided" {
1617 It " throws" {
17- { Add-Account - User hello } | Should Throw " Provide a password"
18+ { Add-Account - User hello } | Should - Throw " Provide a password"
1819 }
1920 }
2021
2122 Context " when the username and password are valid" {
22- $timestamp = (get-date - UFormat " %s" - Millisecond 0 )
23- $user = " TestUser_$timestamp "
24- $password = " Password123!"
23+ BeforeAll {
24+ $timestamp = (get-date - UFormat " %s" - Millisecond 0 )
25+ $user = " TestUser_$timestamp "
26+ $password = " Password123!"
27+ }
2528
2629 BeforeEach {
2730 $userExists = !! (Get-LocalUser | Where {$_.Name -eq $user })
@@ -34,14 +37,11 @@ Describe "Account" {
3437 Add-Account - User $user - Password $password
3538 mkdir " C:\Users\$user " - ErrorAction Ignore
3639 $adsi = [ADSI ]" WinNT://$env: COMPUTERNAME "
37- $existing = $adsi.Children | where {$_.SchemaClassName -eq ' user' -and $_.Name -eq $user }
38- $existing | Should Not Be $null
40+ $existing = $adsi.Children | Where-Object {$_.SchemaClassName -eq ' user' -and $_.Name -eq $user }
41+ $existing | Should - Not - Be $null
3942 Remove-Account - User $user
40- $existing = $adsi.Children | where {$_.SchemaClassName -eq ' user' -and $_.Name -eq $user }
41- $existing | Should Be $null
43+ $existing = $adsi.Children | Where-Object {$_.SchemaClassName -eq ' user' -and $_.Name -eq $user }
44+ $existing | Should - Be $null
4245 }
4346 }
4447}
45-
46- Remove-Module - Name BOSH.Account - ErrorAction Ignore
47- Remove-Module - Name BOSH.Utils - ErrorAction Ignore
0 commit comments