Files
ss14-wl/Content.IntegrationTests/NUnit/Constraints/CompConstraintExtensions.cs
T
Moony 9adb10d791 GameTest part 1 (#43182)
* 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>
2026-03-27 19:08:47 +00:00

49 lines
1.6 KiB
C#

#nullable enable
using Content.IntegrationTests.NUnit.Operators;
using NUnit.Framework.Constraints;
using Robust.Shared.GameObjects;
using Robust.UnitTesting;
namespace Content.IntegrationTests.NUnit.Constraints;
/// <summary>
/// Provides <see cref="M:Content.IntegrationTests.NUnit.Constraints.CompConstraintExtensions.extension(NUnit.Framework.Has).Comp``1(Robust.UnitTesting.IIntegrationInstance)">Has.Comp&lt;T&gt;(side)</see>,
/// a constraint that allows you to check for the presence of, or operate on, a component.
/// </summary>
/// <example>
/// <code>
/// // Assert that the server sided entity myEntity has ItemComponent on the server.
/// Assert.That(myEntity, Has.Comp&lt;ItemComponent&gt;(Server));
/// </code>
/// </example>
public static class CompConstraintExtensions
{
extension(Has)
{
public static ResolvableConstraintExpression Comp<T>(IIntegrationInstance instance)
where T : IComponent
{
return new ConstraintExpression().Comp<T>(instance);
}
public static ResolvableConstraintExpression Comp(Type t, IIntegrationInstance instance)
{
return new ConstraintExpression().Comp(t, instance);
}
}
extension(ConstraintExpression expr)
{
public ResolvableConstraintExpression Comp<T>(IIntegrationInstance instance)
where T : IComponent
{
return expr.Append(new CompOperator(typeof(T), instance));
}
public ResolvableConstraintExpression Comp(Type t, IIntegrationInstance instance)
{
return expr.Append(new CompOperator(t, instance));
}
}
}