Files
RobustToolbox/Robust.UnitTesting/RobustIntegrationTest.TestPair.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

79 lines
2.6 KiB
C#

using System.Threading.Tasks;
using Robust.Shared.Log;
using Robust.UnitTesting.Pool;
namespace Robust.UnitTesting;
public partial class RobustIntegrationTest
{
/// <summary>
/// <see cref="TestPair{TServer,TClient}"/> implementation using <see cref="RobustIntegrationTest"/> instances.
/// </summary>
[Virtual]
public class TestPair : TestPair<ServerIntegrationInstance, ClientIntegrationInstance>
{
protected override async Task<ClientIntegrationInstance> GenerateClient()
{
var client = new ClientIntegrationInstance(ClientOptions());
await client.WaitIdleAsync();
client.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
client.CfgMan.OnValueChanged(RTCVars.FailureLogLevel, value => ClientLogHandler.FailureLevel = value, true);
await client.WaitIdleAsync();
return client;
}
protected override async Task<ServerIntegrationInstance> GenerateServer()
{
var server = new ServerIntegrationInstance(ServerOptions());
await server.WaitIdleAsync();
server.Resolve<ILogManager>().GetSawmill("loc").Level = LogLevel.Error;
server.CfgMan.OnValueChanged(RTCVars.FailureLogLevel, value => ServerLogHandler.FailureLevel = value, true);
return server;
}
protected virtual ClientIntegrationOptions ClientOptions()
{
var options = new ClientIntegrationOptions
{
ContentAssemblies = Manager.ClientAssemblies,
OverrideLogHandler = () => ClientLogHandler
};
options.Options = new()
{
LoadConfigAndUserData = false,
LoadContentResources = false,
};
foreach (var (cvar, value) in Manager.DefaultCvars)
{
options.CVarOverrides[cvar] = value;
}
return options;
}
protected virtual ServerIntegrationOptions ServerOptions()
{
var options = new ServerIntegrationOptions
{
ContentAssemblies = Manager.ServerAssemblies,
OverrideLogHandler = () => ServerLogHandler
};
options.Options = new()
{
LoadConfigAndUserData = false,
LoadContentResources = false,
};
foreach (var (cvar, value) in Manager.DefaultCvars)
{
options.CVarOverrides[cvar] = value;
}
return options;
}
}
}