mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-06-09 10:06:46 +02:00
9adb10d791
* Ports much of GameTest, minus all the WIP stuff. * remark. * EnsureCVar now adds test properties. * Some cleanup and functionality. * Ignore broken test. Needs fixed eventually. Also explicit context config. * TrackingIssue attribute. * oops * Pair config attribute. * Remove SystemAttribute in favor of using the EntitySystemManager dependency collection. * Ensure idleness. * More tests for tests. * More specific failure catching tests. * Reverse attribute resolution order so suite-wide attributes happen first. * Get rid of AffectedProperties again because I need to refactor PoolSettings for that. * Poke * Final cleanup pass. * Update Content.IntegrationTests/Fixtures/Attributes/RunOnSideAttribute.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.IntegrationTests/Fixtures/Attributes/Side.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Update Content.IntegrationTests/NUnit/Utilities/ITestExtensions.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Fixes. * shut up nunit. * Make TrackingIssue a bit strict on purpose, so people don't put junk here. * Update Content.IntegrationTests/Tests/GameTestTests/DisconnectedDependencyTest.cs Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Address. --------- Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
#nullable enable
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Content.IntegrationTests.NUnit.Utilities;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Toolshed.TypeParsers;
|
|
using Robust.UnitTesting;
|
|
|
|
namespace Content.IntegrationTests.NUnit.Constraints;
|
|
|
|
public static class ConstraintHelpers
|
|
{
|
|
/// <summary>
|
|
/// A constraint implementation helper to convert TActual into an entityuid.
|
|
/// </summary>
|
|
/// <param name="t">The input value to try to get an entity uid from.</param>
|
|
/// <param name="instance">The integration test instance to resolve the entity from.</param>
|
|
/// <param name="ent">The resulting entity uid.</param>
|
|
/// <param name="validType">Whether TActual is recognized to begin with.</param>
|
|
/// <typeparam name="TActual">The type to cast out of.</typeparam>
|
|
public static bool TryActualAsEnt<TActual>(TActual t, IIntegrationInstance instance, [NotNullWhen(true)] out EntityUid? ent, out bool validType)
|
|
{
|
|
if (t is EntityUid u)
|
|
{
|
|
ent = u;
|
|
validType = false;
|
|
return true;
|
|
}
|
|
|
|
if (t is IAsType<EntityUid> asTy)
|
|
{
|
|
ent = asTy.AsType();
|
|
validType = false;
|
|
return true;
|
|
}
|
|
|
|
if (t is IResolvesToEntity resolvable)
|
|
{
|
|
if (instance is IServerIntegrationInstance)
|
|
{
|
|
ent = resolvable.SEntity;
|
|
}
|
|
else if (instance is IClientIntegrationInstance)
|
|
{
|
|
ent = resolvable.CEntity;
|
|
}
|
|
else
|
|
{
|
|
throw new NotSupportedException($"{t.GetType()} is not a valid kind of IIntegrationInstance");
|
|
}
|
|
|
|
validType = false;
|
|
return ent is not null;
|
|
}
|
|
|
|
if (t is null)
|
|
{
|
|
ent = null;
|
|
validType = false;
|
|
return false;
|
|
}
|
|
|
|
ent = null;
|
|
validType = true; // Dunno what this type is!
|
|
return false;
|
|
}
|
|
}
|