-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create mock data for testing purposes
- Loading branch information
Showing
21 changed files
with
768 additions
and
10 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
49 changes: 49 additions & 0 deletions
49
DXMainClient/Domain/Multiplayer/CnCNet/QuickMatch/QmMockApiService.cs
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,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ClientCore.Exceptions; | ||
using DTAClient.Domain.Multiplayer.CnCNet.QuickMatch.Models; | ||
using Newtonsoft.Json; | ||
using Rampastring.Tools; | ||
|
||
namespace DTAClient.Domain.Multiplayer.CnCNet.QuickMatch; | ||
|
||
public class QmMockApiService : QmApiService | ||
{ | ||
public override async Task<IEnumerable<QmLadderMap>> LoadLadderMapsForAbbrAsync(string ladderAbbreviation) => LoadMockData<IEnumerable<QmLadderMap>>($"qm_ladder_maps_{ladderAbbreviation}_response.json"); | ||
|
||
public override async Task<QmLadderStats> LoadLadderStatsForAbbrAsync(string ladderAbbreviation) => LoadMockData<QmLadderStats>("qm_ladder_stats_response.json"); | ||
|
||
public override async Task<IEnumerable<QmUserAccount>> LoadUserAccountsAsync() => LoadMockData<IEnumerable<QmUserAccount>>("qm_user_accounts_response.json"); | ||
|
||
public override async Task<IEnumerable<QmLadder>> LoadLaddersAsync() => LoadMockData<IEnumerable<QmLadder>>("qm_ladders_response.json"); | ||
|
||
public override async Task<QmAuthData> LoginAsync(string email, string password) => LoadMockData<QmAuthData>("qm_login_response.json"); | ||
|
||
public override async Task<QmAuthData> RefreshAsync() => LoadMockData<QmAuthData>("qm_login_response.json"); | ||
|
||
public override async Task<QmRequestResponse> QuickMatchRequestAsync(string ladder, string playerName, QmRequest qmRequest) | ||
{ | ||
const string responseType = QmResponseTypes.Wait; | ||
return responseType switch | ||
{ | ||
QmResponseTypes.Error => LoadMockData<QmRequestResponse>("qm_find_match_spawn_response.json"), | ||
QmResponseTypes.Spawn => LoadMockData<QmRequestResponse>("qm_find_match_spawn_response.json"), | ||
QmResponseTypes.Wait => LoadMockData<QmRequestResponse>("qm_find_match_please_wait_response.json"), | ||
_ => throw new NotImplementedException("unknown mock response type") | ||
}; | ||
} | ||
|
||
public override bool IsServerAvailable() => true; | ||
|
||
private T LoadMockData<T>(string mockDataFileName) | ||
{ | ||
string content = File.ReadAllText($"MockData/{mockDataFileName}"); | ||
|
||
return JsonConvert.DeserializeObject<T>(content); | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"type": "fatal", | ||
"message": "fatal message", | ||
"description": "fatal description" | ||
} |
14 changes: 14 additions & 0 deletions
14
DXMainClient/MockData/qm_find_match_game_spawned_request.json
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,14 @@ | ||
{ | ||
"peers": [ | ||
{ | ||
"address": "127.0.0.1", | ||
"id": "1234567890", | ||
"port": 51143, | ||
"rtt": 59 | ||
} | ||
], | ||
"seed": 123, | ||
"status": "GameSpawned", | ||
"type": "update", | ||
"version": "2.0" | ||
} |
3 changes: 3 additions & 0 deletions
3
DXMainClient/MockData/qm_find_match_game_spawned_response.json
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,3 @@ | ||
{ | ||
"message": "update qm match: GameSpawned" | ||
} |
6 changes: 6 additions & 0 deletions
6
DXMainClient/MockData/qm_find_match_gamefinished_request.json
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,6 @@ | ||
{ | ||
"seed": 123, | ||
"status": "GameFinished", | ||
"type": "update", | ||
"version": "1.74" | ||
} |
3 changes: 3 additions & 0 deletions
3
DXMainClient/MockData/qm_find_match_gamefinished_response.json
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,3 @@ | ||
{ | ||
"message": "update qm match: GameFinished" | ||
} |
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,6 @@ | ||
{ | ||
"seed": 123, | ||
"status": "Ready", | ||
"type": "update", | ||
"version": "2.0" | ||
} |
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,3 @@ | ||
{ | ||
"message": "update qm match: Ready" | ||
} |
5 changes: 5 additions & 0 deletions
5
DXMainClient/MockData/qm_find_match_please_wait_response.json
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,5 @@ | ||
{ | ||
"type": "please wait", | ||
"checkback": 10, | ||
"no_sooner_than": 5 | ||
} |
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,6 @@ | ||
{ | ||
"seed": 123, | ||
"status": "Reached", | ||
"type": "update", | ||
"version": "2.0" | ||
} |
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,3 @@ | ||
{ | ||
"message": "update qm match: Reached" | ||
} |
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,52 @@ | ||
{ | ||
"ai_dat": false, | ||
"ddraw": "38f9496b915547ea816a1cd716b65c0d", | ||
"exe_hash": "f265a5c6ce05488884563a5de6e323d7", | ||
"ip_address": "127.0.0.1", | ||
"ip_port": 51143, | ||
"ipv6_address": "", | ||
"ipv6_port": 0, | ||
"lan_ip": "127.0.0.1", | ||
"lan_port": 51143, | ||
"map_bitfield": 2147483647, | ||
"map_sides": [ | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0 | ||
], | ||
"platform": "win32", | ||
"session": "", | ||
"side": 0, | ||
"type": "match me up", | ||
"version": "2.0" | ||
} |
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,50 @@ | ||
{ | ||
"type": "spawn", | ||
"gameID": 456, | ||
"spawn": { | ||
"SpawnLocations": { | ||
"Multi2": -1, | ||
"Multi1": -1 | ||
}, | ||
"Settings": { | ||
"UIMapName": "Test Map", | ||
"MapHash": "35f8f92ebbb94b62918326da5837fedd", | ||
"Seed": 123, | ||
"GameID": 456, | ||
"WOLGameID": 456, | ||
"Host": "No", | ||
"IsSpectator": "No", | ||
"Name": "TestUserMe", | ||
"Port": 51143, | ||
"Side": 0, | ||
"Color": 1, | ||
"GameSpeed": "0", | ||
"Credits": "10000", | ||
"UnitCount": "0", | ||
"Superweapons": "Yes", | ||
"Tournament": "1", | ||
"ShortGame": "Yes", | ||
"Bases": "Yes", | ||
"MCVRedeploy": "Yes", | ||
"MultipleFactory": "Yes", | ||
"Crates": "No", | ||
"GameMode": "Battle", | ||
"FrameSendRate": "4", | ||
"DisableSWvsYuri": "Yes" | ||
}, | ||
"Other1": { | ||
"Name": "TestUser2", | ||
"Side": 0, | ||
"Color": 0, | ||
"Ip": "127.0.0.1", | ||
"Port": 51143, | ||
"IPv6": "", | ||
"PortV6": 0, | ||
"LanIP": "", | ||
"LanPort": 51143 | ||
} | ||
}, | ||
"client": { | ||
"show_map_preview": 1 | ||
} | ||
} |
Oops, something went wrong.