mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests. Tests are now split into separate projects as appropriate, and the API side has also been split off.
48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
|
|
namespace Robust.UnitTesting.Shared.Spawning;
|
|
|
|
[TestFixture]
|
|
internal sealed class TrySpawnInContainerTest : EntitySpawnHelpersTest
|
|
{
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
await Setup();
|
|
|
|
// Spawning into a non-existent container does nothing.
|
|
await Server.WaitPost(() =>
|
|
{
|
|
int count = EntMan.EntityCount;
|
|
Assert.That(EntMan.TrySpawnInContainer(null, ChildA, "foo", out var uid), Is.False);
|
|
Assert.That(EntMan.EntityCount, Is.EqualTo(count));
|
|
Assert.That(EntMan.EntityExists(uid), Is.False);
|
|
Assert.That(EntMan.TrySpawnInContainer(null, GrandChildB, "foo", out uid), Is.False);
|
|
Assert.That(EntMan.EntityCount, Is.EqualTo(count));
|
|
Assert.That(EntMan.EntityExists(uid), Is.False);
|
|
});
|
|
|
|
// Spawning into a container works as expected.
|
|
await Server.WaitPost(() =>
|
|
{
|
|
Assert.That(EntMan.TrySpawnInContainer(null, ChildA, "grandChildA", out var uid));
|
|
Assert.That(EntMan.EntityExists(uid));
|
|
Assert.That(Xforms.GetParentUid(uid!.Value), Is.EqualTo(ChildA));
|
|
Assert.That(Container.IsEntityInContainer(uid.Value));
|
|
Assert.That(Container.GetContainer(ChildA, "grandChildA").Contains(uid.Value));
|
|
});
|
|
|
|
// Spawning another entity will fail as the container is now full
|
|
await Server.WaitPost(() =>
|
|
{
|
|
int count = EntMan.EntityCount;
|
|
Assert.That(EntMan.TrySpawnInContainer(null, ChildA, "grandChildA", out var uid), Is.False);
|
|
Assert.That(EntMan.EntityCount, Is.EqualTo(count));
|
|
Assert.That(EntMan.EntityExists(uid), Is.False);
|
|
});
|
|
|
|
await Server.WaitPost(() => MapSys.DeleteMap(MapId));
|
|
}
|
|
}
|