mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-06-19 14:01:27 +00:00
* Initial implementation of new slot sorting and filtering system * Initial implementation of filtering for lbp3 community tab * Add support for organization on lbp3 * Add playlist and user categories * Implement unit tests for all filters Refactor more systems to use PaginationData * Fix PlayerCountFilter test * Add more unit tests and integration tests for the filter system * Fix LBP2 move filter and gameFilterType * Fix sort by likes in LBP3 category * Add sort for total plays * Remove extra whitespace and make styling more consistent * Order hearted and queued levels by primary key ID * Fix query without order warnings
40 lines
No EOL
1.4 KiB
C#
40 lines
No EOL
1.4 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using LBPUnion.ProjectLighthouse.Configuration;
|
|
using LBPUnion.ProjectLighthouse.Database;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Tests.Helpers;
|
|
|
|
public static class IntegrationHelper
|
|
{
|
|
private static readonly Lazy<bool> dbConnected = new(IsDbConnected);
|
|
|
|
private static bool IsDbConnected() => ServerStatics.DbConnected;
|
|
|
|
/// <summary>
|
|
/// Resets the database to a clean state and returns a new DatabaseContext.
|
|
/// </summary>
|
|
/// <returns>A new fresh instance of DatabaseContext</returns>
|
|
public static async Task<DatabaseContext> GetIntegrationDatabase()
|
|
{
|
|
if (!dbConnected.Value)
|
|
{
|
|
throw new Exception("Database is not connected.\n" +
|
|
"Please ensure that the database is running and that the connection string is correct.\n" +
|
|
$"Connection string: {ServerConfiguration.Instance.DbConnectionString}");
|
|
}
|
|
await ClearRooms();
|
|
await using DatabaseContext database = DatabaseContext.CreateNewInstance();
|
|
await database.Database.EnsureDeletedAsync();
|
|
await database.Database.EnsureCreatedAsync();
|
|
|
|
return DatabaseContext.CreateNewInstance();
|
|
}
|
|
|
|
private static async Task ClearRooms()
|
|
{
|
|
await RoomHelper.Rooms.RemoveAllAsync();
|
|
}
|
|
|
|
} |