-
Notifications
You must be signed in to change notification settings - Fork 14
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 json * cast dates as datetime * revert * fix missing curly bracket * fix test * comment based help
- Loading branch information
Showing
3 changed files
with
137 additions
and
25 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
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,68 @@ | ||
Describe 'Get-SteamPlayerSummary Tests' -Tag 'Unit' { | ||
BeforeAll { | ||
. $SteamPSModulePath\Private\API\Get-SteamAPIKey.ps1 | ||
Mock -CommandName Get-SteamAPIKey -ModuleName SteamPS -MockWith { | ||
return $true | ||
} | ||
} | ||
|
||
Context 'With a valid SteamID64' { | ||
BeforeAll { | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{ | ||
"response": { | ||
"players": [ | ||
{ | ||
"steamid": "12345678901234567", | ||
"communityvisibilitystate": 3, | ||
"profilestate": 1, | ||
"personaname": "TestUser", | ||
"commentpermission": 1, | ||
"profileurl": "https://steamcommunity.com/id/testuser/", | ||
"avatar": "https://example.com/avatar.jpg", | ||
"avatarmedium": "https://example.com/avatar_medium.jpg", | ||
"avatarfull": "https://example.com/avatar_full.jpg", | ||
"avatarhash": "abcdef123456", | ||
"lastlogoff": 1712083677, | ||
"personastate": 1, | ||
"realname": "John Doe", | ||
"primaryclanid": "987654321098765432", | ||
"timecreated": 1577836800, | ||
"gameid": 16900, | ||
"gameserverip": "1.2.3.4", | ||
"gameextrainfo": "Test Game", | ||
"personastateflags": 0, | ||
"loccountrycode": "US", | ||
"locstatecode": "CA", | ||
"loccityid": 54321 | ||
} | ||
] | ||
} | ||
}' | ConvertFrom-Json | ||
} | ||
} | ||
|
||
It 'Should return player summary' { | ||
$PlayerSummary = Get-SteamPlayerSummary -SteamID64 12345678901234567 | ||
$PlayerSummary.SteamID64 | Should -Be '12345678901234567' | ||
$PlayerSummary.PersonaState | Should -BeExactly 'Online' | ||
$PlayerSummary.CommunityVisibilityState | Should -BeExactly 'Public' | ||
$PlayerSummary.LastLogOff | Should -BeExactly '2024-04-02 18:47:57' | ||
$PlayerSummary.TimeCreated | Should -BeExactly '2020-01-01 00:00:00' | ||
$PlayerSummary.GameServerIP | Should -BeExactly '1.2.3.4' | ||
$PlayerSummary.GameServerIP | Should -BeOfType ipaddress | ||
} | ||
} | ||
|
||
Context 'With an invalid SteamID64' { | ||
BeforeAll { | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{"response":{"players":[]}}' | ConvertFrom-Json | ||
} | ||
} | ||
|
||
It 'Should throw an error' { | ||
{ Get-SteamPlayerSummary -SteamID64 1234567890 -ErrorAction Stop } | Should -Throw "SteamID 1234567890 couldn't be found." | ||
} | ||
} | ||
} |