Files
RobustToolbox/Robust.UnitTesting/RobustIntegrationTest.TestPair.cs
Leon Friedrich c458abdc69 Move TestPair & PoolManager to engine (#5877)
* Engine pool manager

* Move documentation

* Move namespace

* Move TestMapData to engine

* Option to prevent loading test assembly

* release notes

* Rename to avoid conflicts
2025-05-10 21:35:28 +10:00

81 lines
2.6 KiB
C#

using System.Threading.Tasks;
using Robust.Client;
using Robust.Server;
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;
}
}
}