mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Add tests for match
This commit is contained in:
parent
a459ef2302
commit
15e3870620
2 changed files with 60 additions and 1 deletions
46
ProjectLighthouse.Tests/Tests/MatchTests.cs
Normal file
46
ProjectLighthouse.Tests/Tests/MatchTests.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectLighthouse.Types;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
public class MatchTests : LighthouseTest {
|
||||
private readonly ITestOutputHelper testOutputHelper;
|
||||
private static SemaphoreSlim semaphore = new(1, 1);
|
||||
public MatchTests(ITestOutputHelper testOutputHelper) {
|
||||
this.testOutputHelper = testOutputHelper;
|
||||
}
|
||||
|
||||
[DatabaseFact]
|
||||
public async Task ShouldReturnOk() {
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
HttpResponseMessage result = await AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
semaphore.Release();
|
||||
}
|
||||
public async Task<int> GetPlayerCount() => Convert.ToInt32(await this.Client.GetStringAsync("LITTLEBIGPLANETPS3_XML/totalPlayerCount"));
|
||||
|
||||
[DatabaseFact]
|
||||
public async Task ShouldIncrementPlayerCount() {
|
||||
LoginResult loginResult = await this.Authenticate(new Random().Next());
|
||||
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
int oldPlayerCount = await this.GetPlayerCount();
|
||||
|
||||
HttpResponseMessage result = await AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
int playerCount = await this.GetPlayerCount();
|
||||
|
||||
semaphore.Release();
|
||||
Assert.Equal(oldPlayerCount + 1, playerCount);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue