-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor cmdlet + test cases * typo * fix error message * add erroraction stop * fix test case with invalid Steam ID * single quotes * comment based help
- Loading branch information
Showing
2 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Describe 'Get-SteamPlayerBan Tests' { | ||
BeforeAll { | ||
. $SteamPSModulePath\Private\API\Get-SteamAPIKey.ps1 | ||
Mock -CommandName Get-SteamAPIKey -ModuleName SteamPS -MockWith { | ||
return $true | ||
} | ||
} | ||
|
||
Context 'With valid Steam ID' { | ||
BeforeAll { | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{ | ||
"players": [ | ||
{ | ||
"SteamId": "76561197983367235", | ||
"CommunityBanned": false, | ||
"VACBanned": false, | ||
"NumberOfVACBans": 0, | ||
"DaysSinceLastBan": 0, | ||
"NumberOfGameBans": 0, | ||
"EconomyBan": "none" | ||
} | ||
] | ||
}' | ConvertFrom-Json | ||
} | ||
} | ||
|
||
It 'Should return ban information' { | ||
$result = Get-SteamPlayerBan -SteamID64 76561197983367235 | ||
$result | Should -Not -BeNullOrEmpty | ||
$result.SteamID64 | Should -BeExactly 76561197983367235 | ||
$result.CommunityBanned | Should -Be $false | ||
$result.VACBanned | Should -Be $false | ||
$result.NumberOfVACBans | Should -Be 0 | ||
$result.DaysSinceLastBan | Should -Be 0 | ||
$result.NumberOfGameBans | Should -Be 0 | ||
$result.EconomyBan | Should -Be 'none' | ||
} | ||
} | ||
|
||
Context 'With invalid Steam ID' { | ||
BeforeAll { | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{"players":[{}]}' | ConvertFrom-Json | ||
} | ||
} | ||
It 'Should throw an error' { | ||
{ Get-SteamPlayerBan -SteamID64 12345 -ErrorAction Stop } | Should -Throw | ||
} | ||
} | ||
} |