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>
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using NUnit.Framework.Constraints;
|
|
using NUnit.Framework.Internal;
|
|
using Robust.UnitTesting;
|
|
|
|
namespace Content.IntegrationTests.NUnit.Constraints;
|
|
|
|
/// <summary>
|
|
/// A prefix constraint like <see cref="PropertyConstraint"/>, for entity components.
|
|
/// </summary>
|
|
/// <seealso cref="CompConstraintExtensions"/>
|
|
public sealed class CompConstraint(Type tComp, IIntegrationInstance instance, IConstraint baseConstraint)
|
|
: PrefixConstraint(baseConstraint, $"component {tComp.Name}")
|
|
{
|
|
public override ConstraintResult ApplyTo<TActual>(TActual actual)
|
|
{
|
|
if (!ConstraintHelpers.TryActualAsEnt(actual, instance, out var ent, out var error))
|
|
{
|
|
if (error)
|
|
{
|
|
throw new NotImplementedException(
|
|
$"The input type {typeof(TActual)} to {nameof(CompExistsConstraint)} is not a supported entity id.");
|
|
}
|
|
|
|
return new ConstraintResult(this, actual, ConstraintStatus.Failure);
|
|
}
|
|
|
|
if (!instance.EntMan.TryGetComponent(ent, tComp, out var comp))
|
|
return new ConstraintResult(this, actual, ConstraintStatus.Failure);
|
|
|
|
var baseResult = Reflect.InvokeApplyTo(constraint: baseConstraint, tComp, comp);
|
|
return new ConstraintResult(this, baseResult.ActualValue, baseResult.Status);
|
|
}
|
|
}
|