Files
Radicade/ServerTests/DbFactoryCollection.cs
T
2026-10-16 23:33:13 -07:00

32 lines
1.3 KiB
C#

using RadicadeServer.Utils;
using Xunit;
namespace RadicadeServer.Tests;
/// <summary>
/// RoomUtils/MatchmakingUtils expose their DbContext factories as process-wide statics, so
/// two test classes that replace them cannot run at the same time - whichever wins would
/// answer the other's queries. xUnit parallelizes classes by default, which made the suite
/// fail depending on scheduling; membership in this collection serializes those classes.
/// </summary>
[CollectionDefinition(Name)]
public class DbFactoryCollection : ICollectionFixture<RegistrationThrottleFixture>
{
public const string Name = "SharesDbFactoryStatics";
}
/// <summary>
/// The registration throttle is process-wide state. This suite creates dozens of accounts from
/// loopback using the same handful of device ids, so without this the run would spend itself
/// refusing its own fixtures and prove nothing about registration. The limits themselves are
/// covered on their own terms by AccountRegistrationTests, which sets its own and puts them back.
/// </summary>
public sealed class RegistrationThrottleFixture
{
public RegistrationThrottleFixture() =>
RegistrationGuard.Configure(
maxCreationsPerIp: int.MaxValue,
maxCreationsPerDevice: int.MaxValue,
minimumDeviceInterval: TimeSpan.Zero);
}