mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
Fix tests
This commit is contained in:
parent
e4f764784e
commit
24b712cd15
4 changed files with 31 additions and 7 deletions
|
@ -23,10 +23,12 @@ namespace LBPUnion.ProjectLighthouse.Tests {
|
|||
|
||||
public async Task<HttpResponseMessage> AuthenticateResponse(int number = 0) {
|
||||
const char nullChar = (char)0x00;
|
||||
const char sepChar = (char)0x20;
|
||||
const string username = "unitTestUser";
|
||||
|
||||
string stringContent = $"{nullChar}{sepChar}{username}{number}{nullChar}";
|
||||
string nullString = "";
|
||||
for(int i = 0; i < 80; i++) nullString += nullChar;
|
||||
|
||||
string stringContent = $"{nullString}{username}{number}{nullChar}";
|
||||
|
||||
HttpResponseMessage response = await this.Client.PostAsync("/LITTLEBIGPLANETPS3_XML/login", new StringContent(stringContent));
|
||||
return response;
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace LBPUnion.ProjectLighthouse.Tests {
|
|||
string responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
Assert.Contains("You are logged in", responseContent);
|
||||
Assert.Contains("You are now logged in", responseContent);
|
||||
}
|
||||
|
||||
[DatabaseFact]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
|
@ -10,11 +11,27 @@ namespace LBPUnion.ProjectLighthouse.Tests {
|
|||
private static readonly SemaphoreSlim semaphore = new(1, 1);
|
||||
|
||||
[DatabaseFact]
|
||||
public async Task ShouldReturnOk() {
|
||||
public async Task ShouldRejectEmptyData() {
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
Assert.False(result.IsSuccessStatusCode);
|
||||
|
||||
semaphore.Release();
|
||||
}
|
||||
|
||||
[DatabaseFact]
|
||||
public async Task ShouldReturnOk() {
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest(
|
||||
"LITTLEBIGPLANETPS3_XML/match",
|
||||
Encoding.ASCII.GetBytes("[UpdateMyPlayerData,[\"Player\":\"1984\"]]"),
|
||||
loginResult.AuthTicket
|
||||
);
|
||||
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
semaphore.Release();
|
||||
|
@ -29,7 +46,12 @@ namespace LBPUnion.ProjectLighthouse.Tests {
|
|||
|
||||
int oldPlayerCount = await this.GetPlayerCount();
|
||||
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest(
|
||||
"LITTLEBIGPLANETPS3_XML/match",
|
||||
Encoding.ASCII.GetBytes("[UpdateMyPlayerData,[\"Player\":\"1984\"]]"),
|
||||
loginResult.AuthTicket
|
||||
);
|
||||
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
int playerCount = await this.GetPlayerCount();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue