mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-21 18:00:56 +00:00
Rename root namespace to LBPUnion.ProjectLighthouse
This commit is contained in:
parent
20b35ec95f
commit
581e6bac2a
58 changed files with 178 additions and 162 deletions
|
@ -1,12 +1,12 @@
|
|||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ProjectLighthouse.Types.Settings;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public sealed class DatabaseFact : FactAttribute {
|
||||
public DatabaseFact() {
|
||||
ServerSettings.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
|
||||
if(!ServerSettings.DbConnected) Skip = "Database not available";
|
||||
if(!ServerSettings.DbConnected) this.Skip = "Database not available";
|
||||
else {
|
||||
using Database database = new();
|
||||
database.Database.Migrate();
|
||||
|
|
|
@ -3,12 +3,12 @@ using System.IO;
|
|||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using ProjectLighthouse.Serialization;
|
||||
using ProjectLighthouse.Types;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class LighthouseTest {
|
||||
public readonly TestServer Server;
|
||||
|
@ -41,7 +41,7 @@ namespace ProjectLighthouse.Tests {
|
|||
return (LoginResult)serializer.Deserialize(new StringReader(responseContent))!;
|
||||
}
|
||||
|
||||
public Task<HttpResponseMessage> AuthenticatedRequest(string endpoint, string mmAuth) => AuthenticatedRequest(endpoint, mmAuth, HttpMethod.Get);
|
||||
public Task<HttpResponseMessage> AuthenticatedRequest(string endpoint, string mmAuth) => this.AuthenticatedRequest(endpoint, mmAuth, HttpMethod.Get);
|
||||
|
||||
public Task<HttpResponseMessage> AuthenticatedRequest(string endpoint, string mmAuth, HttpMethod method) {
|
||||
using var requestMessage = new HttpRequestMessage(method, endpoint);
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
|
||||
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
|
||||
|
||||
<AssemblyName>LBPUnion.ProjectLighthouse.Tests</AssemblyName>
|
||||
|
||||
<RootNamespace>LBPUnion.ProjectLighthouse.Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectLighthouse.Types;
|
||||
using ProjectLighthouse.Types.Settings;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class AuthenticationTests : LighthouseTest {
|
||||
[Fact]
|
||||
public async Task ShouldReturnErrorOnNoPostData() {
|
||||
|
@ -43,7 +43,7 @@ namespace ProjectLighthouse.Tests {
|
|||
public async Task CanUseToken() {
|
||||
LoginResult loginResult = await this.Authenticate();
|
||||
|
||||
HttpResponseMessage response = await AuthenticatedRequest("/LITTLEBIGPLANETPS3_XML/eula", loginResult.AuthTicket);
|
||||
HttpResponseMessage response = await this.AuthenticatedRequest("/LITTLEBIGPLANETPS3_XML/eula", loginResult.AuthTicket);
|
||||
string responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class DatabaseTests : LighthouseTest {
|
||||
[DatabaseFact]
|
||||
public async Task CanCreateUserTwice() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using ProjectLighthouse.Types.Files;
|
||||
using LBPUnion.ProjectLighthouse.Types.Files;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class FileTypeTests {
|
||||
[Fact]
|
||||
public void ShouldRecognizeLevel() {
|
||||
|
|
|
@ -2,10 +2,10 @@ using System;
|
|||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class MatchTests : LighthouseTest {
|
||||
private static readonly SemaphoreSlim semaphore = new(1, 1);
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace ProjectLighthouse.Tests {
|
|||
LoginResult loginResult = await this.Authenticate();
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
HttpResponseMessage result = await AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
semaphore.Release();
|
||||
|
@ -29,7 +29,7 @@ namespace ProjectLighthouse.Tests {
|
|||
|
||||
int oldPlayerCount = await this.GetPlayerCount();
|
||||
|
||||
HttpResponseMessage result = await AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
HttpResponseMessage result = await this.AuthenticatedUploadDataRequest("LITTLEBIGPLANETPS3_XML/match", Array.Empty<byte>(), loginResult.AuthTicket);
|
||||
Assert.True(result.IsSuccessStatusCode);
|
||||
|
||||
int playerCount = await this.GetPlayerCount();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class SerializerTests : LighthouseTest {
|
||||
[Fact]
|
||||
public void BlankElementWorks() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Threading.Tasks;
|
||||
using ProjectLighthouse.Types;
|
||||
using ProjectLighthouse.Types.Levels;
|
||||
using ProjectLighthouse.Types.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class SlotTests : LighthouseTest {
|
||||
[DatabaseFact]
|
||||
public async Task ShouldOnlyShowUsersLevels() {
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Net.Http;
|
|||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
namespace LBPUnion.ProjectLighthouse.Tests {
|
||||
public class UploadTests : LighthouseTest {
|
||||
public UploadTests() {
|
||||
string assetsDirectory = Path.Combine(Environment.CurrentDirectory, "r");
|
||||
|
@ -13,31 +13,31 @@ namespace ProjectLighthouse.Tests {
|
|||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptScript() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/scriptTest", "ExampleFiles/TestScript.ff");
|
||||
HttpResponseMessage response = await this.UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/scriptTest", "ExampleFiles/TestScript.ff");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptFarc() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/farcTest", "ExampleFiles/TestFarc.farc");
|
||||
HttpResponseMessage response = await this.UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/farcTest", "ExampleFiles/TestFarc.farc");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptGarbage() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/garbageTest", "ExampleFiles/TestGarbage.bin");
|
||||
HttpResponseMessage response = await this.UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/garbageTest", "ExampleFiles/TestGarbage.bin");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldAcceptTexture() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/textureTest", "ExampleFiles/TestTexture.tex");
|
||||
HttpResponseMessage response = await this.UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/textureTest", "ExampleFiles/TestTexture.tex");
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldAcceptLevel() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/levelTest", "ExampleFiles/TestLevel.lvl");
|
||||
HttpResponseMessage response = await this.UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/levelTest", "ExampleFiles/TestLevel.lvl");
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue