Files
tbd-station-14/Content.IntegrationTests/Tests/Disposal/DisposalUnitInteractionTest.cs
Tayrtahn af2bea7f66 Add test of disposal unit throw-insert behavior (#39479)
* Add test of disposal unit throw-insert behavior

* Remove initially-empty check
2025-08-27 22:30:53 +02:00

55 lines
1.8 KiB
C#

using Content.IntegrationTests.Tests.Interaction;
using Content.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Disposal;
public sealed class DisposalUnitInteractionTest : InteractionTest
{
private static readonly EntProtoId DisposalUnit = "DisposalUnit";
private static readonly EntProtoId TrashItem = "BrokenBottle";
private const string TestDisposalUnitId = "TestDisposalUnit";
[TestPrototypes]
private static readonly string TestPrototypes = $@"
# A modified disposal unit with a 100% chance of a thrown item being inserted
- type: entity
parent: {DisposalUnit.Id}
id: {TestDisposalUnitId}
components:
- type: ThrowInsertContainer
probability: 1
";
/// <summary>
/// Spawns a disposal unit, gives the player a trash item, and makes the
/// player throw the item at the disposal unit.
/// After a short delay, verifies that the thrown item is contained inside
/// the disposal unit.
/// </summary>
[Test]
public async Task ThrowItemIntoDisposalUnitTest()
{
var containerSys = Server.System<SharedContainerSystem>();
// Spawn the target disposal unit
var disposalUnit = await SpawnTarget(TestDisposalUnitId);
// Give the player some trash to throw
var trash = await PlaceInHands(TrashItem);
// Throw the item at the disposal unit
await ThrowItem();
// Wait a moment
await RunTicks(10);
// Make sure the trash is in the disposal unit
var throwInsertComp = Comp<ThrowInsertContainerComponent>();
var container = containerSys.GetContainer(ToServer(disposalUnit), throwInsertComp.ContainerId);
Assert.That(container.ContainedEntities, Contains.Item(ToServer(trash)));
}
}