Remove PoolSettings.ExtraPrototypes option (#18678)
This commit is contained in:
@@ -26,10 +26,12 @@ public class DeviceNetworkingBenchmark
|
||||
|
||||
|
||||
private NetworkPayload _payload = default!;
|
||||
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: DummyNetworkDevice
|
||||
id: DummyNetworkDevice
|
||||
name: DummyNetworkDevicePrivate
|
||||
id: DummyNetworkDevicePrivate
|
||||
components:
|
||||
- type: DeviceNetwork
|
||||
transmitFrequency: 100
|
||||
@@ -56,7 +58,7 @@ public class DeviceNetworkingBenchmark
|
||||
public async Task SetupAsync()
|
||||
{
|
||||
ProgramShared.PathOffset = "../../../../";
|
||||
_pair = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
_pair = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = _pair.Pair.Server;
|
||||
|
||||
await server.WaitPost(() =>
|
||||
@@ -73,17 +75,23 @@ public class DeviceNetworkingBenchmark
|
||||
["testbool"] = true
|
||||
};
|
||||
|
||||
_sourceEntity = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace);
|
||||
_sourceEntity = entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace);
|
||||
_sourceWirelessEntity = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
|
||||
|
||||
for (var i = 0; i < EntityCount; i++)
|
||||
{
|
||||
_targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace));
|
||||
_targetEntities.Add(entityManager.SpawnEntity("DummyNetworkDevicePrivate", MapCoordinates.Nullspace));
|
||||
_targetWirelessEntities.Add(entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[GlobalCleanup]
|
||||
public async Task Cleanup()
|
||||
{
|
||||
await _pair.DisposeAsync();
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true, Description = "Entity Events")]
|
||||
public async Task EventSentBaseline()
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Content.Benchmarks
|
||||
|
||||
public static async Task MainAsync(string[] args)
|
||||
{
|
||||
PoolManager.Startup(typeof(Program).Assembly);
|
||||
var pair = await PoolManager.GetServerClient();
|
||||
var gameMaps = pair.Pair.Server.ResolveDependency<IPrototypeManager>().EnumeratePrototypes<GameMapPrototype>().ToList();
|
||||
MapLoadBenchmark.MapsSource = gameMaps.Select(x => x.ID);
|
||||
@@ -33,6 +34,8 @@ namespace Content.Benchmarks
|
||||
var config = Environment.GetEnvironmentVariable("ROBUST_BENCHMARKS_ENABLE_SQL") != null ? DefaultSQLConfig.Instance : null;
|
||||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
|
||||
#endif
|
||||
|
||||
PoolManager.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
Content.IntegrationTests/PoolManager.Prototypes.cs
Normal file
38
Content.IntegrationTests/PoolManager.Prototypes.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.IntegrationTests;
|
||||
|
||||
// Partial class for handling the discovering and storing test prototypes.
|
||||
public static partial class PoolManager
|
||||
{
|
||||
private static List<string> _testPrototypes = new();
|
||||
|
||||
private const BindingFlags Flags = BindingFlags.Static
|
||||
| BindingFlags.NonPublic
|
||||
| BindingFlags.Public
|
||||
| BindingFlags.DeclaredOnly;
|
||||
|
||||
private static void DiscoverTestPrototypes(Assembly? assembly = null)
|
||||
{
|
||||
assembly ??= typeof(PoolManager).Assembly;
|
||||
_testPrototypes.Clear();
|
||||
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
foreach (var field in type.GetFields(Flags))
|
||||
{
|
||||
if (!field.HasCustomAttribute<TestPrototypesAttribute>())
|
||||
continue;
|
||||
|
||||
var val = field.GetValue(null);
|
||||
if (val is not string str)
|
||||
throw new Exception($"TestPrototypeAttribute is only valid on non-null string fields");
|
||||
|
||||
_testPrototypes.Add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Content.Client.IoC;
|
||||
@@ -27,6 +29,7 @@ using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.UnitTesting;
|
||||
|
||||
[assembly: LevelOfParallelism(3)]
|
||||
@@ -36,7 +39,7 @@ namespace Content.IntegrationTests;
|
||||
/// <summary>
|
||||
/// Making clients, and servers is slow, this manages a pool of them so tests can reuse them.
|
||||
/// </summary>
|
||||
public static class PoolManager
|
||||
public static partial class PoolManager
|
||||
{
|
||||
public const string TestMap = "Empty";
|
||||
|
||||
@@ -62,23 +65,12 @@ public static class PoolManager
|
||||
|
||||
private static int _pairId;
|
||||
private static readonly object PairLock = new();
|
||||
private static bool _initialized;
|
||||
|
||||
// Pair, IsBorrowed
|
||||
private static readonly Dictionary<Pair, bool> Pairs = new();
|
||||
private static bool _dead;
|
||||
private static Exception _poolFailureReason;
|
||||
|
||||
private static async Task ConfigurePrototypes(RobustIntegrationTest.IntegrationInstance instance,
|
||||
PoolSettings settings)
|
||||
{
|
||||
await instance.WaitPost(() =>
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var changes = new Dictionary<Type, HashSet<string>>();
|
||||
prototypeManager.LoadString(settings.ExtraPrototypes.Trim(), true, changes);
|
||||
prototypeManager.ReloadPrototypes(changes);
|
||||
});
|
||||
}
|
||||
private static Exception? _poolFailureReason;
|
||||
|
||||
private static async Task<(RobustIntegrationTest.ServerIntegrationInstance, PoolTestLogHandler)> GenerateServer(
|
||||
PoolSettings poolSettings,
|
||||
@@ -86,7 +78,6 @@ public static class PoolManager
|
||||
{
|
||||
var options = new RobustIntegrationTest.ServerIntegrationOptions
|
||||
{
|
||||
ExtraPrototypes = poolSettings.ExtraPrototypes,
|
||||
ContentStart = true,
|
||||
Options = new ServerOptions()
|
||||
{
|
||||
@@ -144,6 +135,8 @@ public static class PoolManager
|
||||
{
|
||||
pair.Kill();
|
||||
}
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
public static string DeathReport()
|
||||
@@ -174,7 +167,6 @@ public static class PoolManager
|
||||
{
|
||||
FailureLogLevel = LogLevel.Warning,
|
||||
ContentStart = true,
|
||||
ExtraPrototypes = poolSettings.ExtraPrototypes,
|
||||
ContentAssemblies = new[]
|
||||
{
|
||||
typeof(Shared.Entry.EntryPoint).Assembly,
|
||||
@@ -257,7 +249,7 @@ public static class PoolManager
|
||||
/// </summary>
|
||||
/// <param name="poolSettings">See <see cref="PoolSettings"/></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<PairTracker> GetServerClient(PoolSettings poolSettings = null)
|
||||
public static async Task<PairTracker> GetServerClient(PoolSettings? poolSettings = null)
|
||||
{
|
||||
return await GetServerClientPair(poolSettings ?? new PoolSettings());
|
||||
}
|
||||
@@ -269,6 +261,9 @@ public static class PoolManager
|
||||
|
||||
private static async Task<PairTracker> GetServerClientPair(PoolSettings poolSettings)
|
||||
{
|
||||
if (!_initialized)
|
||||
throw new InvalidOperationException($"Pool manager has not been initialized");
|
||||
|
||||
// Trust issues with the AsyncLocal that backs this.
|
||||
var testContext = TestContext.CurrentContext;
|
||||
var testOut = TestContext.Out;
|
||||
@@ -277,7 +272,7 @@ public static class PoolManager
|
||||
var currentTestName = poolSettings.TestName ?? GetDefaultTestName(testContext);
|
||||
var poolRetrieveTimeWatch = new Stopwatch();
|
||||
await testOut.WriteLineAsync($"{nameof(GetServerClientPair)}: Called by test {currentTestName}");
|
||||
Pair pair = null;
|
||||
Pair? pair = null;
|
||||
try
|
||||
{
|
||||
poolRetrieveTimeWatch.Start();
|
||||
@@ -386,11 +381,11 @@ public static class PoolManager
|
||||
Assert.That(status, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
private static Pair GrabOptimalPair(PoolSettings poolSettings)
|
||||
private static Pair? GrabOptimalPair(PoolSettings poolSettings)
|
||||
{
|
||||
lock (PairLock)
|
||||
{
|
||||
Pair fallback = null;
|
||||
Pair? fallback = null;
|
||||
foreach (var pair in Pairs.Keys)
|
||||
{
|
||||
if (Pairs[pair])
|
||||
@@ -457,7 +452,7 @@ public static class PoolManager
|
||||
cNetMgr.ClientConnect(null!, 0, null!);
|
||||
});
|
||||
}
|
||||
await ReallyBeIdle(pair, 11);
|
||||
await ReallyBeIdle(pair, 5);
|
||||
|
||||
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Disconnecting client, and restarting server");
|
||||
|
||||
@@ -466,43 +461,7 @@ public static class PoolManager
|
||||
cNetMgr.ClientDisconnect("Test pooling cleanup disconnect");
|
||||
});
|
||||
|
||||
await ReallyBeIdle(pair, 10);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(pair.Settings.ExtraPrototypes))
|
||||
{
|
||||
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Removing prototypes");
|
||||
if (!pair.Settings.NoServer)
|
||||
{
|
||||
var serverProtoManager = pair.Server.ResolveDependency<IPrototypeManager>();
|
||||
await pair.Server.WaitPost(() =>
|
||||
{
|
||||
serverProtoManager.RemoveString(pair.Settings.ExtraPrototypes.Trim());
|
||||
});
|
||||
}
|
||||
if (!pair.Settings.NoClient)
|
||||
{
|
||||
var clientProtoManager = pair.Client.ResolveDependency<IPrototypeManager>();
|
||||
await pair.Client.WaitPost(() =>
|
||||
{
|
||||
clientProtoManager.RemoveString(pair.Settings.ExtraPrototypes.Trim());
|
||||
});
|
||||
}
|
||||
|
||||
await ReallyBeIdle(pair, 1);
|
||||
}
|
||||
|
||||
if (poolSettings.ExtraPrototypes != null)
|
||||
{
|
||||
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Adding prototypes");
|
||||
if (!poolSettings.NoServer)
|
||||
{
|
||||
await ConfigurePrototypes(pair.Server, poolSettings);
|
||||
}
|
||||
if (!poolSettings.NoClient)
|
||||
{
|
||||
await ConfigurePrototypes(pair.Client, poolSettings);
|
||||
}
|
||||
}
|
||||
await ReallyBeIdle(pair, 5);
|
||||
|
||||
configManager.SetCVar(CCVars.GameMap, poolSettings.Map);
|
||||
await testOut.WriteLineAsync($"Recycling: {methodWatch.Elapsed.TotalMilliseconds} ms: Restarting server again");
|
||||
@@ -548,6 +507,7 @@ we are just going to end this here to save a lot of time. This is the exception
|
||||
Assert.Fail("The pool was shut down");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<Pair> CreateServerClientPair(PoolSettings poolSettings, TextWriter testOut)
|
||||
{
|
||||
Pair pair;
|
||||
@@ -563,6 +523,9 @@ we are just going to end this here to save a lot of time. This is the exception
|
||||
ClientLogHandler = clientLog,
|
||||
PairId = Interlocked.Increment(ref _pairId)
|
||||
};
|
||||
|
||||
if (!poolSettings.NoLoadTestPrototypes)
|
||||
await pair.LoadPrototypes(_testPrototypes!);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -757,6 +720,19 @@ we are just going to end this here to save a lot of time. This is the exception
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the pool manager.
|
||||
/// </summary>
|
||||
/// <param name="assembly">Assembly to search for to discover extra test prototypes.</param>
|
||||
public static void Startup(Assembly? assembly)
|
||||
{
|
||||
if (_initialized)
|
||||
throw new InvalidOperationException("Already initialized");
|
||||
|
||||
_initialized = true;
|
||||
DiscoverTestPrototypes(assembly);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -766,17 +742,15 @@ we are just going to end this here to save a lot of time. This is the exception
|
||||
/// </summary>
|
||||
public sealed class PoolSettings
|
||||
{
|
||||
// TODO: We can make more of these pool-able, if we need enough of them for it to matter
|
||||
|
||||
/// <summary>
|
||||
/// If the returned pair must not be reused
|
||||
/// </summary>
|
||||
public bool MustNotBeReused => Destructive || NoLoadContent || NoToolsExtraPrototypes;
|
||||
public bool MustNotBeReused => Destructive || NoLoadContent || NoLoadTestPrototypes;
|
||||
|
||||
/// <summary>
|
||||
/// If the given pair must be brand new
|
||||
/// </summary>
|
||||
public bool MustBeNew => Fresh || NoLoadContent || NoToolsExtraPrototypes;
|
||||
public bool MustBeNew => Fresh || NoLoadContent || NoLoadTestPrototypes;
|
||||
|
||||
/// <summary>
|
||||
/// If the given pair must not be connected
|
||||
@@ -816,9 +790,11 @@ public sealed class PoolSettings
|
||||
public bool NoLoadContent { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Set this to raw yaml text to load prototypes onto the given server/client pair.
|
||||
/// This will return a server-client pair that has not loaded test prototypes.
|
||||
/// Try avoiding this whenever possible, as this will always create & destroy a new pair.
|
||||
/// Use <see cref="Pair.IsTestPrototype(EntityPrototype)"/> if you need to exclude test prototypees.
|
||||
/// </summary>
|
||||
public string ExtraPrototypes { get; init; }
|
||||
public bool NoLoadTestPrototypes { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Set this to true to disable the NetInterp CVar on the given server/client pair
|
||||
@@ -848,7 +824,7 @@ public sealed class PoolSettings
|
||||
/// <summary>
|
||||
/// Overrides the test name detection, and uses this in the test history instead
|
||||
/// </summary>
|
||||
public string TestName { get; set; }
|
||||
public string? TestName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tries to guess if we can skip recycling the server/client pair.
|
||||
@@ -870,19 +846,8 @@ public sealed class PoolSettings
|
||||
return NotConnected == nextSettings.NotConnected
|
||||
&& DummyTicker == nextSettings.DummyTicker
|
||||
&& Map == nextSettings.Map
|
||||
&& InLobby == nextSettings.InLobby
|
||||
&& ExtraPrototypes == nextSettings.ExtraPrototypes;
|
||||
&& InLobby == nextSettings.InLobby;
|
||||
}
|
||||
|
||||
// Prototype hot reload is not available outside TOOLS builds,
|
||||
// so we can't pool test instances that use ExtraPrototypes without TOOLS.
|
||||
#if TOOLS
|
||||
#pragma warning disable CA1822 // Can't be marked as static b/c the other branch exists but Omnisharp can't see both.
|
||||
private bool NoToolsExtraPrototypes => false;
|
||||
#pragma warning restore CA1822
|
||||
#else
|
||||
private bool NoToolsExtraPrototypes => !string.IsNullOrEmpty(ExtraPrototypes);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -893,7 +858,7 @@ public sealed class TestMapData
|
||||
public EntityUid MapUid { get; set; }
|
||||
public EntityUid GridUid { get; set; }
|
||||
public MapId MapId { get; set; }
|
||||
public MapGridComponent MapGrid { get; set; }
|
||||
public MapGridComponent MapGrid { get; set; } = default!;
|
||||
public EntityCoordinates GridCoords { get; set; }
|
||||
public MapCoordinates MapCoords { get; set; }
|
||||
public TileRef Tile { get; set; }
|
||||
@@ -907,12 +872,15 @@ public sealed class Pair
|
||||
public bool Dead { get; private set; }
|
||||
public int PairId { get; init; }
|
||||
public List<string> TestHistory { get; set; } = new();
|
||||
public PoolSettings Settings { get; set; }
|
||||
public RobustIntegrationTest.ServerIntegrationInstance Server { get; init; }
|
||||
public RobustIntegrationTest.ClientIntegrationInstance Client { get; init; }
|
||||
public PoolSettings Settings { get; set; } = default!;
|
||||
public RobustIntegrationTest.ServerIntegrationInstance Server { get; init; } = default!;
|
||||
public RobustIntegrationTest.ClientIntegrationInstance Client { get; init; } = default!;
|
||||
|
||||
public PoolTestLogHandler ServerLogHandler { get; init; }
|
||||
public PoolTestLogHandler ClientLogHandler { get; init; }
|
||||
public PoolTestLogHandler ServerLogHandler { get; init; } = default!;
|
||||
public PoolTestLogHandler ClientLogHandler { get; init; } = default!;
|
||||
|
||||
private Dictionary<Type, HashSet<string>> _loadedPrototypes = new();
|
||||
private HashSet<string> _loadedEntityPrototypes = new();
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
@@ -932,6 +900,57 @@ public sealed class Pair
|
||||
ServerLogHandler.ActivateContext(testOut);
|
||||
ClientLogHandler.ActivateContext(testOut);
|
||||
}
|
||||
|
||||
public async Task LoadPrototypes(List<string> prototypes)
|
||||
{
|
||||
await LoadPrototypes(Server, prototypes);
|
||||
await LoadPrototypes(Client, prototypes);
|
||||
}
|
||||
|
||||
private async Task LoadPrototypes(RobustIntegrationTest.IntegrationInstance instance, List<string> prototypes)
|
||||
{
|
||||
var changed = new Dictionary<Type, HashSet<string>>();
|
||||
var protoMan = instance.ResolveDependency<IPrototypeManager>();
|
||||
foreach (var file in prototypes)
|
||||
{
|
||||
protoMan.LoadString(file, changed: changed);
|
||||
}
|
||||
|
||||
await instance.WaitPost(() => protoMan.ReloadPrototypes(changed));
|
||||
|
||||
foreach (var (kind, ids) in changed)
|
||||
{
|
||||
_loadedPrototypes.GetOrNew(kind).UnionWith(ids);
|
||||
}
|
||||
|
||||
if (_loadedPrototypes.TryGetValue(typeof(EntityPrototype), out var entIds))
|
||||
_loadedEntityPrototypes.UnionWith(entIds);
|
||||
}
|
||||
|
||||
public bool IsTestPrototype(EntityPrototype proto)
|
||||
{
|
||||
return _loadedEntityPrototypes.Contains(proto.ID);
|
||||
}
|
||||
|
||||
public bool IsTestEntityPrototype(string id)
|
||||
{
|
||||
return _loadedEntityPrototypes.Contains(id);
|
||||
}
|
||||
|
||||
public bool IsTestPrototype<TPrototype>(string id) where TPrototype : IPrototype
|
||||
{
|
||||
return IsTestPrototype(typeof(TPrototype), id);
|
||||
}
|
||||
|
||||
public bool IsTestPrototype<TPrototype>(TPrototype proto) where TPrototype : IPrototype
|
||||
{
|
||||
return IsTestPrototype(typeof(TPrototype), proto.ID);
|
||||
}
|
||||
|
||||
public bool IsTestPrototype(Type kind, string id)
|
||||
{
|
||||
return _loadedPrototypes.TryGetValue(kind, out var ids) && ids.Contains(id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -941,8 +960,8 @@ public sealed class PairTracker : IAsyncDisposable
|
||||
{
|
||||
private readonly TextWriter _testOut;
|
||||
private int _disposed;
|
||||
public Stopwatch UsageWatch { get; set; }
|
||||
public Pair Pair { get; init; }
|
||||
public Stopwatch UsageWatch { get; set; } = default!;
|
||||
public Pair Pair { get; init; } = default!;
|
||||
|
||||
public PairTracker(TextWriter testOut)
|
||||
{
|
||||
|
||||
@@ -9,9 +9,11 @@ public sealed class PoolManagerTestEventHandler
|
||||
// This value is completely arbitrary.
|
||||
private static TimeSpan MaximumTotalTestingTimeLimit => TimeSpan.FromMinutes(20);
|
||||
private static TimeSpan HardStopTimeLimit => MaximumTotalTestingTimeLimit.Add(TimeSpan.FromMinutes(1));
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void Setup()
|
||||
{
|
||||
PoolManager.Startup(typeof(PoolManagerTestEventHandler).Assembly);
|
||||
// If the tests seem to be stuck, we try to end it semi-nicely
|
||||
_ = Task.Delay(MaximumTotalTestingTimeLimit).ContinueWith(_ =>
|
||||
{
|
||||
|
||||
9
Content.IntegrationTests/TestPrototypesAttribute.cs
Normal file
9
Content.IntegrationTests/TestPrototypesAttribute.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.IntegrationTests;
|
||||
|
||||
/// <summary>
|
||||
/// Attribute that indicates that a string contains yaml prototype data that should be loaded by integration tests.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public sealed class TestPrototypesAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -7,9 +7,10 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
[TestOf(typeof(AtmosAlarmThreshold))]
|
||||
public sealed class AlarmThresholdTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: alarmThreshold
|
||||
id: testThreshold
|
||||
id: AlarmThresholdTestDummy
|
||||
upperBound: !type:AlarmThresholdSetting
|
||||
threshold: 5
|
||||
lowerBound: !type:AlarmThresholdSetting
|
||||
@@ -23,7 +24,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
[Test]
|
||||
public async Task TestAlarmThreshold()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||
@@ -31,7 +32,7 @@ namespace Content.IntegrationTests.Tests.Atmos
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
threshold = prototypeManager.Index<AtmosAlarmThreshold>("testThreshold");
|
||||
threshold = prototypeManager.Index<AtmosAlarmThreshold>("AlarmThresholdTestDummy");
|
||||
});
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
[TestOf(typeof(BodyComponent))]
|
||||
public sealed class LegTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanBodyAndAppearanceDummy
|
||||
@@ -30,8 +31,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
[TestOf(typeof(LungSystem))]
|
||||
public sealed class LungTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanBodyDummy
|
||||
id: HumanBodyDummy
|
||||
name: HumanLungDummy
|
||||
id: HumanLungDummy
|
||||
components:
|
||||
- type: SolutionContainerManager
|
||||
- type: Body
|
||||
@@ -54,8 +55,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
// --- Setup
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
{
|
||||
var coords = new Vector2(0.5f, -1f);
|
||||
var coordinates = new EntityCoordinates(grid.Value, coords);
|
||||
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
|
||||
human = entityManager.SpawnEntity("HumanLungDummy", coordinates);
|
||||
respSys = entityManager.System<RespiratorSystem>();
|
||||
metaSys = entityManager.System<MetabolizerSystem>();
|
||||
relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(grid.Value);
|
||||
@@ -143,8 +143,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -179,7 +178,7 @@ namespace Content.IntegrationTests.Tests.Body
|
||||
var center = new Vector2(0.5f, 0.5f);
|
||||
|
||||
var coordinates = new EntityCoordinates(grid.Value, center);
|
||||
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
|
||||
human = entityManager.SpawnEntity("HumanLungDummy", coordinates);
|
||||
|
||||
var mixture = entityManager.System<AtmosphereSystem>().GetContainingMixture(human);
|
||||
#pragma warning disable NUnit2045
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Content.IntegrationTests.Tests.Body;
|
||||
[TestFixture]
|
||||
public sealed class SaveLoadReparentTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanBodyDummy
|
||||
@@ -25,8 +26,7 @@ public sealed class SaveLoadReparentTest
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
private const string StrapDummyId = "StrapDummy";
|
||||
private const string ItemDummyId = "ItemDummy";
|
||||
|
||||
private static readonly string Prototypes = $@"
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = $@"
|
||||
- type: entity
|
||||
name: {BuckleDummyId}
|
||||
id: {BuckleDummyId}
|
||||
@@ -49,7 +50,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
public async Task BuckleUnbuckleCooldownRangeTest()
|
||||
{
|
||||
await using var pairTracker =
|
||||
await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
|
||||
await PoolManager.GetServerClient();
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -244,8 +245,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -341,8 +341,7 @@ namespace Content.IntegrationTests.Tests.Buckle
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ public sealed class CargoTest
|
||||
|
||||
var protoIds = protoManager.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !p.Components.ContainsKey("MapGrid")) // Grids are not for sale.
|
||||
.Select(p => p.ID)
|
||||
.ToList();
|
||||
@@ -144,10 +145,9 @@ public sealed class CargoTest
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task StackPrice()
|
||||
{
|
||||
const string stackProto = @"
|
||||
|
||||
[TestPrototypes]
|
||||
private const string StackProto = @"
|
||||
- type: entity
|
||||
id: A
|
||||
|
||||
@@ -165,7 +165,11 @@ public sealed class CargoTest
|
||||
count: 5
|
||||
";
|
||||
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = stackProto });
|
||||
[Test]
|
||||
public async Task StackPrice()
|
||||
{
|
||||
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true } );
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Content.IntegrationTests.Tests.Chemistry;
|
||||
[TestOf(typeof(SolutionContainerSystem))]
|
||||
public sealed class SolutionSystemTests
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: SolutionTarget
|
||||
@@ -47,8 +48,7 @@ public sealed class SolutionSystemTests
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -95,8 +95,7 @@ public sealed class SolutionSystemTests
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -143,8 +142,7 @@ public sealed class SolutionSystemTests
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -202,8 +200,7 @@ public sealed class SolutionSystemTests
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -241,7 +238,7 @@ public sealed class SolutionSystemTests
|
||||
[Test]
|
||||
public async Task TestTemperatureCalculations()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||
const float temp = 100.0f;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
[TestOf(typeof(ReactionPrototype))]
|
||||
public sealed class TryAllReactionsTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: TestSolutionContainer
|
||||
@@ -22,13 +23,13 @@ namespace Content.IntegrationTests.Tests.Chemistry
|
||||
beaker:
|
||||
maxVol: 50
|
||||
canMix: true";
|
||||
|
||||
[Test]
|
||||
public async Task TryAllTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
[TestOf(typeof(RejuvenateSystem))]
|
||||
public sealed class RejuvenateTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: DamageableDummy
|
||||
@@ -34,8 +35,7 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.Construction
|
||||
{
|
||||
foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.Abstract || !proto.Components.TryGetValue(name, out var reg))
|
||||
if (proto.Abstract || pairTracker.Pair.IsTestPrototype(proto) || !proto.Components.TryGetValue(name, out var reg))
|
||||
continue;
|
||||
|
||||
var comp = (ConstructionComponent) reg.Component;
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
public sealed class ContainerOcclusionTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: ContainerOcclusionA
|
||||
@@ -33,7 +34,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestA()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient();
|
||||
var s = pairTracker.Pair.Server;
|
||||
var c = pairTracker.Pair.Client;
|
||||
|
||||
@@ -73,7 +74,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestB()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient();
|
||||
var s = pairTracker.Pair.Server;
|
||||
var c = pairTracker.Pair.Client;
|
||||
|
||||
@@ -113,7 +114,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestAb()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient();
|
||||
var s = pairTracker.Pair.Server;
|
||||
var c = pairTracker.Pair.Client;
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Content.IntegrationTests.Tests.Damageable
|
||||
[TestOf(typeof(DamageableSystem))]
|
||||
public sealed class DamageableTest
|
||||
{
|
||||
public const string Prototypes = @"
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
# Define some damage groups
|
||||
- type: damageType
|
||||
id: TestDamage1
|
||||
@@ -74,8 +75,7 @@ namespace Content.IntegrationTests.Tests.Damageable
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
public const string DestructibleDamageTypeEntityId = "DestructibleTestsDestructibleDamageTypeEntity";
|
||||
public const string DestructibleDamageGroupEntityId = "DestructibleTestsDestructibleDamageGroupEntity";
|
||||
|
||||
public static readonly string Prototypes = $@"
|
||||
[TestPrototypes]
|
||||
public const string DamagePrototypes = $@"
|
||||
- type: damageType
|
||||
id: TestBlunt
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ namespace Content.IntegrationTests.Tests.Destructible
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
[TestOf(typeof(WirelessNetworkComponent))]
|
||||
public sealed class DeviceNetworkTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: DummyNetworkDevice
|
||||
@@ -36,8 +37,8 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
- type: ApcPowerReceiver
|
||||
|
||||
- type: entity
|
||||
name: DummyWirelessNetworkDevice
|
||||
id: DummyWirelessNetworkDevice
|
||||
name: WirelessNetworkDeviceDummy
|
||||
id: WirelessNetworkDeviceDummy
|
||||
components:
|
||||
- type: DeviceNetwork
|
||||
transmitFrequency: 100
|
||||
@@ -52,8 +53,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -116,8 +116,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -144,7 +143,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
device1 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", coordinates);
|
||||
device1 = entityManager.SpawnEntity("WirelessNetworkDeviceDummy", coordinates);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
@@ -157,7 +156,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty));
|
||||
});
|
||||
|
||||
device2 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", new MapCoordinates(new Vector2(0, 50), testMap.MapId));
|
||||
device2 = entityManager.SpawnEntity("WirelessNetworkDeviceDummy", new MapCoordinates(new Vector2(0, 50), testMap.MapId));
|
||||
|
||||
Assert.That(entityManager.TryGetComponent(device2, out networkComponent2), Is.True);
|
||||
Assert.Multiple(() =>
|
||||
@@ -205,8 +204,7 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
|
||||
@@ -72,10 +72,11 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
});
|
||||
}
|
||||
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanDummy
|
||||
id: HumanDummy
|
||||
name: HumanDisposalDummy
|
||||
id: HumanDisposalDummy
|
||||
components:
|
||||
- type: Body
|
||||
prototype: Human
|
||||
@@ -148,8 +149,7 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Content.IntegrationTests.Tests.Disposal
|
||||
{
|
||||
// Spawn the entities
|
||||
var coordinates = testMap.GridCoords;
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
human = entityManager.SpawnEntity("HumanDisposalDummy", coordinates);
|
||||
wrench = entityManager.SpawnEntity("WrenchDummy", coordinates);
|
||||
disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates);
|
||||
disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy",
|
||||
|
||||
@@ -12,10 +12,11 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
[TestOf(typeof(DoAfterComponent))]
|
||||
public sealed class DoAfterServerTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: Dummy
|
||||
id: Dummy
|
||||
name: DoAfterDummy
|
||||
id: DoAfterDummy
|
||||
components:
|
||||
- type: DoAfter
|
||||
";
|
||||
@@ -60,8 +61,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
await server.WaitIdleAsync();
|
||||
@@ -75,7 +75,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var tickTime = 1.0f / timing.TickRate;
|
||||
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
|
||||
var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace);
|
||||
var args = new DoAfterArgs(mob, tickTime / 2, ev, null) { Broadcast = true };
|
||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||
Assert.That(doAfterSystem.TryStartDoAfter(args));
|
||||
@@ -94,8 +94,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
@@ -107,7 +106,7 @@ namespace Content.IntegrationTests.Tests.DoAfter
|
||||
{
|
||||
var tickTime = 1.0f / timing.TickRate;
|
||||
|
||||
var mob = entityManager.SpawnEntity("Dummy", MapCoordinates.Nullspace);
|
||||
var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace);
|
||||
var args = new DoAfterArgs(mob, tickTime * 2, ev, null) { Broadcast = true };
|
||||
|
||||
if (!doAfterSystem.TryStartDoAfter(args, out var id))
|
||||
|
||||
@@ -13,10 +13,11 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
[TestOf(typeof(AirlockComponent))]
|
||||
public sealed class AirlockTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: PhysicsDummy
|
||||
id: PhysicsDummy
|
||||
name: AirlockPhysicsDummy
|
||||
id: AirlockPhysicsDummy
|
||||
components:
|
||||
- type: Physics
|
||||
bodyType: Dynamic
|
||||
@@ -54,8 +55,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -117,8 +117,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -130,24 +129,24 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
var xformSystem = entityManager.System<SharedTransformSystem>();
|
||||
|
||||
PhysicsComponent physBody = null;
|
||||
EntityUid physicsDummy = default;
|
||||
EntityUid AirlockPhysicsDummy = default;
|
||||
EntityUid airlock = default;
|
||||
DoorComponent doorComponent = null;
|
||||
|
||||
var physicsDummyStartingX = -1;
|
||||
var AirlockPhysicsDummyStartingX = -1;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
|
||||
var humanCoordinates = new MapCoordinates(new Vector2(physicsDummyStartingX, 0), mapId);
|
||||
physicsDummy = entityManager.SpawnEntity("PhysicsDummy", humanCoordinates);
|
||||
var humanCoordinates = new MapCoordinates(new Vector2(AirlockPhysicsDummyStartingX, 0), mapId);
|
||||
AirlockPhysicsDummy = entityManager.SpawnEntity("AirlockPhysicsDummy", humanCoordinates);
|
||||
|
||||
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates(new Vector2(0, 0), mapId));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(entityManager.TryGetComponent(physicsDummy, out physBody), Is.True);
|
||||
Assert.That(entityManager.TryGetComponent(AirlockPhysicsDummy, out physBody), Is.True);
|
||||
Assert.That(entityManager.TryGetComponent(airlock, out doorComponent), Is.True);
|
||||
});
|
||||
Assert.That(doorComponent.State, Is.EqualTo(DoorState.Closed));
|
||||
@@ -159,7 +158,7 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
await server.WaitAssertion(() => Assert.That(physBody, Is.Not.EqualTo(null)));
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
physicsSystem.SetLinearVelocity(physicsDummy, new Vector2(0.5f, 0f), body: physBody);
|
||||
physicsSystem.SetLinearVelocity(AirlockPhysicsDummy, new Vector2(0.5f, 0f), body: physBody);
|
||||
});
|
||||
|
||||
for (var i = 0; i < 240; i += 10)
|
||||
@@ -178,12 +177,12 @@ namespace Content.IntegrationTests.Tests.Doors
|
||||
// Sloth: Okay I'm sorry but I hate having to rewrite tests for every refactor
|
||||
// If you see this yell at me in discord so I can continue to pretend this didn't happen.
|
||||
// REMINDER THAT I STILL HAVE TO FIX THIS TEST EVERY OTHER PHYSICS PR
|
||||
// Assert.That(physicsDummy.Transform.MapPosition.X, Is.GreaterThan(physicsDummyStartingX));
|
||||
// Assert.That(AirlockPhysicsDummy.Transform.MapPosition.X, Is.GreaterThan(AirlockPhysicsDummyStartingX));
|
||||
|
||||
// Blocked by the airlock
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(Math.Abs(xformSystem.GetWorldPosition(physicsDummy).X - 1), Is.GreaterThan(0.01f));
|
||||
Assert.That(Math.Abs(xformSystem.GetWorldPosition(AirlockPhysicsDummy).X - 1), Is.GreaterThan(0.01f));
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.NoSpawn || proto.Abstract || !proto.Components.ContainsKey("Sprite"))
|
||||
if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto) || !proto.Components.ContainsKey("Sprite"))
|
||||
continue;
|
||||
|
||||
Assert.DoesNotThrow(() =>
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Content.IntegrationTests.Tests
|
||||
var protoIds = prototypeMan
|
||||
.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
||||
.Select(p => p.ID)
|
||||
.ToList();
|
||||
@@ -90,6 +91,7 @@ namespace Content.IntegrationTests.Tests
|
||||
var protoIds = prototypeMan
|
||||
.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
||||
.Select(p => p.ID)
|
||||
.ToList();
|
||||
@@ -146,6 +148,7 @@ namespace Content.IntegrationTests.Tests
|
||||
var protoIds = prototypeMan
|
||||
.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !p.Components.ContainsKey("MapGrid")) // This will smash stuff otherwise.
|
||||
.Select(p => p.ID)
|
||||
.ToList();
|
||||
|
||||
@@ -16,10 +16,11 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
[TestOf(typeof(HandcuffComponent))]
|
||||
public sealed class HandCuffTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanDummy
|
||||
id: HumanDummy
|
||||
name: HumanHandcuffDummy
|
||||
id: HumanHandcuffDummy
|
||||
components:
|
||||
- type: Cuffable
|
||||
- type: Hands
|
||||
@@ -38,8 +39,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -64,8 +64,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
// Spawn the entities
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
otherHuman = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
human = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
|
||||
otherHuman = entityManager.SpawnEntity("HumanHandcuffDummy", coordinates);
|
||||
cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
||||
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
||||
|
||||
|
||||
@@ -9,18 +9,19 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
[TestOf(typeof(GravityGeneratorComponent))]
|
||||
public sealed class WeightlessStatusTests
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanDummy
|
||||
id: HumanDummy
|
||||
name: HumanWeightlessDummy
|
||||
id: HumanWeightlessDummy
|
||||
components:
|
||||
- type: Alerts
|
||||
- type: Physics
|
||||
bodyType: Dynamic
|
||||
|
||||
- type: entity
|
||||
name: GravityGeneratorDummy
|
||||
id: GravityGeneratorDummy
|
||||
name: WeightlessGravityGeneratorDummy
|
||||
id: WeightlessGravityGeneratorDummy
|
||||
components:
|
||||
- type: GravityGenerator
|
||||
chargeRate: 1000000000 # Set this really high so it discharges in a single tick.
|
||||
@@ -34,8 +35,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
human = entityManager.SpawnEntity("HumanDummy", testMap.GridCoords);
|
||||
human = entityManager.SpawnEntity("HumanWeightlessDummy", testMap.GridCoords);
|
||||
|
||||
Assert.That(entityManager.TryGetComponent(human, out AlertsComponent alerts));
|
||||
});
|
||||
@@ -61,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Gravity
|
||||
// No gravity without a gravity generator
|
||||
Assert.That(alertsSystem.IsShowingAlert(human, AlertType.Weightless));
|
||||
|
||||
generatorUid = entityManager.SpawnEntity("GravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
|
||||
generatorUid = entityManager.SpawnEntity("WeightlessGravityGeneratorDummy", entityManager.GetComponent<TransformComponent>(human).Coordinates);
|
||||
});
|
||||
|
||||
// Let WeightlessSystem and GravitySystem tick
|
||||
|
||||
@@ -15,10 +15,11 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestOf(typeof(GravityGeneratorComponent))]
|
||||
public sealed class GravityGridTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: GravityGeneratorDummy
|
||||
id: GravityGeneratorDummy
|
||||
name: GridGravityGeneratorDummy
|
||||
id: GridGravityGeneratorDummy
|
||||
components:
|
||||
- type: GravityGenerator
|
||||
chargeRate: 1000000000 # Set this really high so it discharges in a single tick.
|
||||
@@ -31,8 +32,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Content.IntegrationTests.Tests
|
||||
grid1Entity = grid1.Owner;
|
||||
grid2Entity = grid2.Owner;
|
||||
|
||||
generator = entityMan.SpawnEntity("GravityGeneratorDummy", grid2.ToCoordinates());
|
||||
generator = entityMan.SpawnEntity("GridGravityGeneratorDummy", grid2.ToCoordinates());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(entityMan.HasComponent<GravityGeneratorComponent>(generator));
|
||||
|
||||
@@ -9,10 +9,11 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestFixture]
|
||||
public sealed class HumanInventoryUniformSlotsTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanDummy
|
||||
id: HumanDummy
|
||||
name: HumanUniformDummy
|
||||
id: HumanUniformDummy
|
||||
components:
|
||||
- type: Inventory
|
||||
- type: ContainerContainer
|
||||
@@ -54,7 +55,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
var coordinates = testMap.GridCoords;
|
||||
@@ -71,7 +72,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
invSystem = entityMan.System<InventorySystem>();
|
||||
|
||||
human = entityMan.SpawnEntity("HumanDummy", coordinates);
|
||||
human = entityMan.SpawnEntity("HumanUniformDummy", coordinates);
|
||||
uniform = entityMan.SpawnEntity("UniformDummy", coordinates);
|
||||
idCard = entityMan.SpawnEntity("IDCardDummy", coordinates);
|
||||
pocketItem = entityMan.SpawnEntity("FlashlightDummy", coordinates);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
[TestOf(typeof(InteractionSystem))]
|
||||
public sealed class InteractionSystemTests
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: DummyDebugWall
|
||||
@@ -40,8 +41,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -114,8 +114,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -120,7 +120,8 @@ public abstract partial class InteractionTest
|
||||
|
||||
|
||||
// Simple mob that has one hand and can perform misc interactions.
|
||||
public const string TestPrototypes = @"
|
||||
[TestPrototypes]
|
||||
private const string TestPrototypes = @"
|
||||
- type: entity
|
||||
id: InteractionTestMob
|
||||
components:
|
||||
@@ -139,7 +140,7 @@ public abstract partial class InteractionTest
|
||||
[SetUp]
|
||||
public virtual async Task Setup()
|
||||
{
|
||||
PairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = TestPrototypes });
|
||||
PairTracker = await PoolManager.GetServerClient();
|
||||
|
||||
// server dependencies
|
||||
SEntMan = Server.ResolveDependency<IEntityManager>();
|
||||
@@ -239,7 +240,7 @@ public abstract partial class InteractionTest
|
||||
await PairTracker.CleanReturnAsync();
|
||||
await TearDown();
|
||||
}
|
||||
|
||||
|
||||
protected virtual async Task TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestFixture]
|
||||
public sealed class InventoryHelpersTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: InventoryStunnableDummy
|
||||
@@ -40,7 +41,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task SpawnItemInSlotTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var sEntities = server.ResolveDependency<IEntityManager>();
|
||||
|
||||
@@ -38,7 +38,10 @@ public sealed class MachineBoardTest
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID)))
|
||||
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !_ignoredPrototypes.Contains(p.ID)))
|
||||
{
|
||||
if (!p.TryGetComponent<MachineBoardComponent>(out var mbc))
|
||||
continue;
|
||||
@@ -74,7 +77,10 @@ public sealed class MachineBoardTest
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID)))
|
||||
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pairTracker.Pair.IsTestPrototype(p))
|
||||
.Where(p => !_ignoredPrototypes.Contains(p.ID)))
|
||||
{
|
||||
if (!p.TryGetComponent<ComputerBoardComponent>(out var cbc))
|
||||
continue;
|
||||
|
||||
@@ -65,7 +65,7 @@ public sealed class MaterialArbitrageTest
|
||||
Dictionary<string, ConstructionComponent> constructionRecipes = new();
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.NoSpawn || proto.Abstract)
|
||||
if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
|
||||
continue;
|
||||
|
||||
if (!proto.Components.TryGetValue(constructionName, out var destructible))
|
||||
@@ -125,7 +125,7 @@ public sealed class MaterialArbitrageTest
|
||||
// Here we get the set of entities/materials spawned when destroying an entity.
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.NoSpawn || proto.Abstract)
|
||||
if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
|
||||
continue;
|
||||
|
||||
if (!proto.Components.TryGetValue(destructibleName, out var destructible))
|
||||
@@ -290,7 +290,7 @@ public sealed class MaterialArbitrageTest
|
||||
Dictionary<string, PhysicalCompositionComponent> physicalCompositions = new();
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.NoSpawn || proto.Abstract)
|
||||
if (proto.NoSpawn || proto.Abstract || pairTracker.Pair.IsTestPrototype(proto))
|
||||
continue;
|
||||
|
||||
if (!proto.Components.TryGetValue(compositionName, out var composition))
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Content.IntegrationTests.Tests.Minds;
|
||||
[TestFixture]
|
||||
public sealed class GhostRoleTests
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: GhostRoleTestEntity
|
||||
@@ -29,7 +30,7 @@ public sealed class GhostRoleTests
|
||||
[Test]
|
||||
public async Task TakeRoleAndReturn()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient();
|
||||
var server = pairTracker.Pair.Server;
|
||||
var client = pairTracker.Pair.Client;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Content.IntegrationTests.Tests.Minds;
|
||||
[TestFixture]
|
||||
public sealed partial class MindTests
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: MindTestEntityDamageable
|
||||
@@ -109,7 +110,7 @@ public sealed partial class MindTests
|
||||
[Test]
|
||||
public async Task TestEntityDeadWhenGibbed()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var entMan = server.ResolveDependency<IServerEntityManager>();
|
||||
|
||||
@@ -42,6 +42,26 @@ namespace Content.IntegrationTests.Tests
|
||||
"/Maps/infiltrator.yml",
|
||||
};
|
||||
|
||||
private static readonly string[] GameMaps =
|
||||
{
|
||||
"Dev",
|
||||
"Fland",
|
||||
"Meta",
|
||||
"Packed",
|
||||
"Aspid",
|
||||
"Cluster",
|
||||
"Omega",
|
||||
"Bagel",
|
||||
"Origin",
|
||||
"CentComm",
|
||||
"Box",
|
||||
"Barratry",
|
||||
"Saltern",
|
||||
"Core",
|
||||
"Marathon",
|
||||
"Kettle"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that specific files have been saved as grids and not maps.
|
||||
/// </summary>
|
||||
@@ -128,53 +148,7 @@ namespace Content.IntegrationTests.Tests
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
private static string[] GetGameMapNames()
|
||||
{
|
||||
Task<string[]> task;
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
task = Task.Run(static async () =>
|
||||
{
|
||||
await Task.Yield();
|
||||
await using var pairTracker = await PoolManager.GetServerClient(
|
||||
new PoolSettings
|
||||
{
|
||||
Disconnected = true,
|
||||
TestName = $"{nameof(PostMapInitTest)}.{nameof(GetGameMapNames)}"
|
||||
}
|
||||
);
|
||||
var server = pairTracker.Pair.Server;
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
var maps = protoManager.EnumeratePrototypes<GameMapPrototype>().ToList();
|
||||
var mapNames = new List<string>();
|
||||
var naughty = new HashSet<string>()
|
||||
{
|
||||
PoolManager.TestMap,
|
||||
"Infiltrator",
|
||||
"Pirate",
|
||||
};
|
||||
|
||||
foreach (var map in maps)
|
||||
{
|
||||
// AAAAAAAAAA
|
||||
// Why are they stations!
|
||||
if (naughty.Contains(map.ID))
|
||||
continue;
|
||||
|
||||
mapNames.Add(map.ID);
|
||||
}
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
return mapNames.ToArray();
|
||||
});
|
||||
Task.WaitAny(task);
|
||||
}
|
||||
|
||||
return task.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource(nameof(GetGameMapNames))]
|
||||
[Test, TestCaseSource(nameof(GameMaps))]
|
||||
public async Task GameMapsLoadableTest(string mapProto)
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
@@ -306,86 +280,89 @@ namespace Content.IntegrationTests.Tests
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the non-game map maps.
|
||||
/// </summary>
|
||||
private static string[] GetMaps()
|
||||
[Test]
|
||||
public async Task AllMapsTested()
|
||||
{
|
||||
Task<string[]> task;
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
task = Task.Run(static async () =>
|
||||
{
|
||||
await Task.Yield();
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { Disconnected = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var resourceManager = server.ResolveDependency<IResourceManager>();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings {NoClient = true});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
var gameMaps = protoManager.EnumeratePrototypes<GameMapPrototype>().Select(o => o.MapPath).ToHashSet();
|
||||
var gameMaps = protoMan.EnumeratePrototypes<GameMapPrototype>()
|
||||
.Where(x => !pairTracker.Pair.IsTestPrototype(x))
|
||||
.Select(x => x.ID)
|
||||
.ToHashSet();
|
||||
|
||||
var mapFolder = new ResPath("/Maps");
|
||||
var maps = resourceManager
|
||||
.ContentFindFiles(mapFolder)
|
||||
.Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".", StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
var mapNames = new List<string>();
|
||||
foreach (var map in maps)
|
||||
{
|
||||
var rootedPath = map.ToRootedPath();
|
||||
Assert.That(gameMaps.Remove(PoolManager.TestMap));
|
||||
|
||||
// ReSharper disable once RedundantLogicalConditionalExpressionOperand
|
||||
if (SkipTestMaps && rootedPath.ToString().StartsWith(TestMapsPath, StringComparison.Ordinal) ||
|
||||
gameMaps.Contains(map))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
mapNames.Add(rootedPath.ToString());
|
||||
}
|
||||
CollectionAssert.AreEquivalent(GameMaps.ToHashSet(), gameMaps, "Game map prototype missing from test cases.");
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
return mapNames.ToArray();
|
||||
});
|
||||
Task.WaitAny(task);
|
||||
}
|
||||
|
||||
return task.GetAwaiter().GetResult();
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource(nameof(GetMaps))]
|
||||
public async Task MapsLoadableTest(string mapName)
|
||||
[Test]
|
||||
public async Task NonGameMapsLoadableTest()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var resourceManager = server.ResolveDependency<IResourceManager>();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var cfg = server.ResolveDependency<IConfigurationManager>();
|
||||
Assert.That(cfg.GetCVar(CCVars.GridFill), Is.False);
|
||||
|
||||
var gameMaps = protoManager.EnumeratePrototypes<GameMapPrototype>().Select(o => o.MapPath).ToHashSet();
|
||||
|
||||
var mapFolder = new ResPath("/Maps");
|
||||
var maps = resourceManager
|
||||
.ContentFindFiles(mapFolder)
|
||||
.Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".", StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
|
||||
var mapNames = new List<string>();
|
||||
foreach (var map in maps)
|
||||
{
|
||||
if (gameMaps.Contains(map))
|
||||
continue;
|
||||
|
||||
var rootedPath = map.ToRootedPath();
|
||||
if (SkipTestMaps && rootedPath.ToString().StartsWith(TestMapsPath, StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
mapNames.Add(rootedPath.ToString());
|
||||
}
|
||||
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
try
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mapLoader.TryLoad(mapId, mapName, out _));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Failed to load map {mapName}", ex);
|
||||
}
|
||||
foreach (var mapName in mapNames)
|
||||
{
|
||||
var mapId = mapManager.CreateMap();
|
||||
try
|
||||
{
|
||||
Assert.That(mapLoader.TryLoad(mapId, mapName, out _));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Failed to load map {mapName}", ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mapManager.DeleteMap(mapId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Failed to delete map {mapName}", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
mapManager.DeleteMap(mapId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Failed to delete map {mapName}", ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
[TestFixture]
|
||||
public sealed class PowerTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
id: GeneratorDummy
|
||||
@@ -163,8 +164,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -228,8 +228,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -289,8 +288,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -380,8 +378,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -483,7 +480,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
// checks that batteries and supplies properly ramp down if the load is disconnected/disabled.
|
||||
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
@@ -581,8 +578,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -641,8 +637,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -722,8 +717,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -803,8 +797,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -901,7 +894,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
[Test]
|
||||
public async Task TestSupplyPrioritized()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
@@ -1001,8 +994,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -1092,8 +1084,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -1180,8 +1171,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -1249,8 +1239,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -1308,8 +1297,7 @@ namespace Content.IntegrationTests.Tests.Power
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
|
||||
@@ -81,6 +81,9 @@ public sealed class PrototypeSaveTest
|
||||
if (prototype.Abstract)
|
||||
continue;
|
||||
|
||||
if (pairTracker.Pair.IsTestPrototype(prototype))
|
||||
continue;
|
||||
|
||||
// Yea this test just doesn't work with this, it parents a grid to another grid and causes game logic to explode.
|
||||
if (prototype.Components.ContainsKey("MapGrid"))
|
||||
continue;
|
||||
|
||||
@@ -62,6 +62,9 @@ public sealed class ResearchTest
|
||||
if (proto.Abstract)
|
||||
continue;
|
||||
|
||||
if (pairTracker.Pair.IsTestPrototype(proto))
|
||||
continue;
|
||||
|
||||
if (!proto.TryGetComponent<LatheComponent>(out var lathe))
|
||||
continue;
|
||||
allLathes.Add(lathe);
|
||||
|
||||
@@ -18,9 +18,10 @@ namespace Content.IntegrationTests.Tests.Station;
|
||||
[TestOf(typeof(StationJobsSystem))]
|
||||
public sealed class StationJobsTest
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: playTimeTracker
|
||||
id: Dummy
|
||||
id: PlayTimeDummy
|
||||
|
||||
- type: gameMap
|
||||
id: FooStation
|
||||
@@ -43,26 +44,26 @@ public sealed class StationJobsTest
|
||||
|
||||
- type: job
|
||||
id: TAssistant
|
||||
playTimeTracker: Dummy
|
||||
playTimeTracker: PlayTimeDummy
|
||||
|
||||
- type: job
|
||||
id: TMime
|
||||
weight: 20
|
||||
playTimeTracker: Dummy
|
||||
playTimeTracker: PlayTimeDummy
|
||||
|
||||
- type: job
|
||||
id: TClown
|
||||
weight: -10
|
||||
playTimeTracker: Dummy
|
||||
playTimeTracker: PlayTimeDummy
|
||||
|
||||
- type: job
|
||||
id: TCaptain
|
||||
weight: 10
|
||||
playTimeTracker: Dummy
|
||||
playTimeTracker: PlayTimeDummy
|
||||
|
||||
- type: job
|
||||
id: TChaplain
|
||||
playTimeTracker: Dummy
|
||||
playTimeTracker: PlayTimeDummy
|
||||
";
|
||||
|
||||
private const int StationCount = 100;
|
||||
@@ -75,8 +76,7 @@ public sealed class StationJobsTest
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -153,8 +153,7 @@ public sealed class StationJobsTest
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
@@ -208,8 +207,7 @@ public sealed class StationJobsTest
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -15,14 +15,15 @@ namespace Content.IntegrationTests.Tests.Tag
|
||||
private const string TagEntityId = "TagTestDummy";
|
||||
|
||||
// Register these three into the prototype manager
|
||||
private const string StartingTag = "A";
|
||||
private const string AddedTag = "EIOU";
|
||||
private const string UnusedTag = "E";
|
||||
private const string StartingTag = "StartingTagDummy";
|
||||
private const string AddedTag = "AddedTagDummy";
|
||||
private const string UnusedTag = "UnusedTagDummy";
|
||||
|
||||
// Do not register this one
|
||||
private const string UnregisteredTag = "AAAAAAAAA";
|
||||
|
||||
private static readonly string Prototypes = $@"
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = $@"
|
||||
- type: Tag
|
||||
id: {StartingTag}
|
||||
|
||||
@@ -45,8 +46,7 @@ namespace Content.IntegrationTests.Tests.Tag
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
{
|
||||
private const string BlockerDummyId = "BlockerDummy";
|
||||
|
||||
private static readonly string Prototypes = $@"
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = $@"
|
||||
- type: entity
|
||||
id: {BlockerDummyId}
|
||||
name: {BlockerDummyId}
|
||||
@@ -33,8 +34,7 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
NoClient = true
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
private const string InvalidComponent = "Sprite";
|
||||
private const string ValidComponent = "Physics";
|
||||
|
||||
private static readonly string Prototypes = $@"
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = $@"
|
||||
- type: Tag
|
||||
id: ValidTag
|
||||
id: WhitelistTestValidTag
|
||||
- type: Tag
|
||||
id: InvalidTag
|
||||
id: WhitelistTestInvalidTag
|
||||
|
||||
- type: entity
|
||||
id: WhitelistDummy
|
||||
@@ -30,34 +31,34 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
components:
|
||||
- {ValidComponent}
|
||||
tags:
|
||||
- ValidTag
|
||||
- WhitelistTestValidTag
|
||||
|
||||
- type: entity
|
||||
id: InvalidComponentDummy
|
||||
components:
|
||||
- type: {InvalidComponent}
|
||||
- type: entity
|
||||
id: InvalidTagDummy
|
||||
id: WhitelistTestInvalidTagDummy
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- InvalidTag
|
||||
- WhitelistTestInvalidTag
|
||||
|
||||
- type: entity
|
||||
id: ValidComponentDummy
|
||||
components:
|
||||
- type: {ValidComponent}
|
||||
- type: entity
|
||||
id: ValidTagDummy
|
||||
id: WhitelistTestValidTagDummy
|
||||
components:
|
||||
- type: Tag
|
||||
tags:
|
||||
- ValidTag";
|
||||
- WhitelistTestValidTag";
|
||||
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
var testMap = await PoolManager.CreateTestMap(pairTracker);
|
||||
@@ -68,16 +69,16 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
var validComponent = sEntities.SpawnEntity("ValidComponentDummy", mapCoordinates);
|
||||
var validTag = sEntities.SpawnEntity("ValidTagDummy", mapCoordinates);
|
||||
var WhitelistTestValidTag = sEntities.SpawnEntity("WhitelistTestValidTagDummy", mapCoordinates);
|
||||
|
||||
var invalidComponent = sEntities.SpawnEntity("InvalidComponentDummy", mapCoordinates);
|
||||
var invalidTag = sEntities.SpawnEntity("InvalidTagDummy", mapCoordinates);
|
||||
var WhitelistTestInvalidTag = sEntities.SpawnEntity("WhitelistTestInvalidTagDummy", mapCoordinates);
|
||||
|
||||
// Test instantiated on its own
|
||||
var whitelistInst = new EntityWhitelist
|
||||
{
|
||||
Components = new[] { $"{ValidComponent}" },
|
||||
Tags = new() { "ValidTag" }
|
||||
Tags = new() { "WhitelistTestValidTag" }
|
||||
};
|
||||
whitelistInst.UpdateRegistrations();
|
||||
Assert.That(whitelistInst, Is.Not.Null);
|
||||
@@ -91,10 +92,10 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(whitelistInst.IsValid(validComponent), Is.True);
|
||||
Assert.That(whitelistInst.IsValid(validTag), Is.True);
|
||||
Assert.That(whitelistInst.IsValid(WhitelistTestValidTag), Is.True);
|
||||
|
||||
Assert.That(whitelistInst.IsValid(invalidComponent), Is.False);
|
||||
Assert.That(whitelistInst.IsValid(invalidTag), Is.False);
|
||||
Assert.That(whitelistInst.IsValid(WhitelistTestInvalidTag), Is.False);
|
||||
});
|
||||
|
||||
// Test from serialized
|
||||
@@ -111,10 +112,10 @@ namespace Content.IntegrationTests.Tests.Utility
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(whitelistSer.IsValid(validComponent), Is.True);
|
||||
Assert.That(whitelistSer.IsValid(validTag), Is.True);
|
||||
Assert.That(whitelistSer.IsValid(WhitelistTestValidTag), Is.True);
|
||||
|
||||
Assert.That(whitelistSer.IsValid(invalidComponent), Is.False);
|
||||
Assert.That(whitelistSer.IsValid(invalidTag), Is.False);
|
||||
Assert.That(whitelistSer.IsValid(WhitelistTestInvalidTag), Is.False);
|
||||
});
|
||||
});
|
||||
await pairTracker.CleanReturnAsync();
|
||||
|
||||
@@ -11,6 +11,7 @@ using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.VendingMachines;
|
||||
using Content.Shared.Wires;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -19,10 +20,11 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestOf(typeof(VendingMachineSystem))]
|
||||
public sealed class VendingMachineRestockTest : EntitySystem
|
||||
{
|
||||
[TestPrototypes]
|
||||
private const string Prototypes = @"
|
||||
- type: entity
|
||||
name: HumanDummy
|
||||
id: HumanDummy
|
||||
name: HumanVendingDummy
|
||||
id: HumanVendingDummy
|
||||
components:
|
||||
- type: Hands
|
||||
- type: Body
|
||||
@@ -117,8 +119,9 @@ namespace Content.IntegrationTests.Tests
|
||||
// Collect all the prototypes with restock components.
|
||||
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (proto.Abstract ||
|
||||
!proto.TryGetComponent<VendingMachineRestockComponent>(out var restock))
|
||||
if (proto.Abstract
|
||||
|| pairTracker.Pair.IsTestPrototype(proto)
|
||||
|| !proto.HasComponent<VendingMachineRestockComponent>())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -173,7 +176,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestCompleteRestockProcess()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -197,7 +200,7 @@ namespace Content.IntegrationTests.Tests
|
||||
var coordinates = testMap.GridCoords;
|
||||
|
||||
// Spawn the entities.
|
||||
user = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
user = entityManager.SpawnEntity("HumanVendingDummy", coordinates);
|
||||
machine = entityManager.SpawnEntity("VendingMachineTest", coordinates);
|
||||
packageRight = entityManager.SpawnEntity("TestRestockCorrect", coordinates);
|
||||
packageWrong = entityManager.SpawnEntity("TestRestockWrong", coordinates);
|
||||
@@ -259,7 +262,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestRestockBreaksOpen()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
@@ -323,7 +326,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[Test]
|
||||
public async Task TestRestockInventoryBounds()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
|
||||
var server = pairTracker.Pair.Server;
|
||||
await server.WaitIdleAsync();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Content.MapRenderer
|
||||
if (!CommandLineArguments.TryParse(args, out var arguments))
|
||||
return;
|
||||
|
||||
PoolManager.Startup(null);
|
||||
if (arguments.Maps.Count == 0)
|
||||
{
|
||||
Console.WriteLine("Didn't specify any maps to paint! Loading the map list...");
|
||||
@@ -135,6 +136,7 @@ namespace Content.MapRenderer
|
||||
}
|
||||
|
||||
await Run(arguments);
|
||||
PoolManager.Shutdown();
|
||||
}
|
||||
|
||||
private static async Task Run(CommandLineArguments arguments)
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Content.YAMLLinter
|
||||
{
|
||||
private static async Task<int> Main(string[] _)
|
||||
{
|
||||
PoolManager.Startup(null);
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace Content.YAMLLinter
|
||||
}
|
||||
|
||||
Console.WriteLine($"{count} errors found in {(int) stopwatch.Elapsed.TotalMilliseconds} ms.");
|
||||
PoolManager.Shutdown();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user