Add integration test for the RCD (#40625)

* rcd test

* fixes

* fix

* space

* review
This commit is contained in:
slarticodefast
2025-10-04 12:18:38 +02:00
committed by GitHub
parent 6661449633
commit 690bb5a8f2
2 changed files with 274 additions and 7 deletions

View File

@@ -726,7 +726,7 @@ public abstract partial class InteractionTest
tile = MapSystem.GetTileRef(gridUid, grid, serverCoords).Tile;
});
Assert.That(tile.TypeId, Is.EqualTo(targetTile.TypeId));
Assert.That(tile.TypeId, Is.EqualTo(targetTile.TypeId), $"Expected tile at NetCoordinates {coords}: {TileMan[targetTile.TypeId].Name}. But was: {TileMan[tile.TypeId].Name}");
}
protected void AssertGridCount(int value)
@@ -742,6 +742,20 @@ public abstract partial class InteractionTest
Assert.That(count, Is.EqualTo(value));
}
/// <summary>
/// Check that some entity is close to a certain coordinate location.
/// </summary>
/// <param name="target">The entity to check the location for. Defaults to <see cref="target"/></param>
/// <param name="coordinates">The coordinates the entity should be at.</param>
/// <param name="radius">The maximum allowed distance from the target coords</param>
protected void AssertLocation(NetEntity? target, NetCoordinates coords, float radius = 0.01f)
{
target ??= Target;
Assert.That(target, Is.Not.Null, "No target specified");
Assert.That(Position(target!.Value).TryDelta(SEntMan, Transform, ToServer(coords), out var delta), "Could not calculate distance between coordinates.");
Assert.That(delta.Length(), Is.LessThanOrEqualTo(radius), $"{SEntMan.ToPrettyString(SEntMan.GetEntity(target.Value))} was not at the intended location. Distance: {delta}, allowed distance: {radius}");
}
#endregion
#region Entity lookups
@@ -986,9 +1000,9 @@ public abstract partial class InteractionTest
/// <summary>
/// Sends a bui message using the given bui key.
/// </summary>
protected async Task SendBui(Enum key, BoundUserInterfaceMessage msg, EntityUid? _ = null)
protected async Task SendBui(Enum key, BoundUserInterfaceMessage msg, NetEntity? target = null)
{
if (!TryGetBui(key, out var bui))
if (!TryGetBui(key, out var bui, target))
return;
await Client.WaitPost(() => bui.SendMessage(msg));
@@ -1000,9 +1014,9 @@ public abstract partial class InteractionTest
/// <summary>
/// Sends a bui message using the given bui key.
/// </summary>
protected async Task CloseBui(Enum key, EntityUid? _ = null)
protected async Task CloseBui(Enum key, NetEntity? target = null)
{
if (!TryGetBui(key, out var bui))
if (!TryGetBui(key, out var bui, target))
return;
await Client.WaitPost(() => bui.Close());
@@ -1424,15 +1438,25 @@ public abstract partial class InteractionTest
protected EntityUid? ToServer(NetEntity? nent) => SEntMan.GetEntity(nent);
protected EntityUid? ToClient(NetEntity? nent) => CEntMan.GetEntity(nent);
protected EntityUid ToServer(EntityUid cuid) => SEntMan.GetEntity(CEntMan.GetNetEntity(cuid));
protected EntityUid ToClient(EntityUid cuid) => CEntMan.GetEntity(SEntMan.GetNetEntity(cuid));
protected EntityUid ToClient(EntityUid suid) => CEntMan.GetEntity(SEntMan.GetNetEntity(suid));
protected EntityUid? ToServer(EntityUid? cuid) => SEntMan.GetEntity(CEntMan.GetNetEntity(cuid));
protected EntityUid? ToClient(EntityUid? cuid) => CEntMan.GetEntity(SEntMan.GetNetEntity(cuid));
protected EntityUid? ToClient(EntityUid? suid) => CEntMan.GetEntity(SEntMan.GetNetEntity(suid));
protected EntityCoordinates ToServer(NetCoordinates coords) => SEntMan.GetCoordinates(coords);
protected EntityCoordinates ToClient(NetCoordinates coords) => CEntMan.GetCoordinates(coords);
protected EntityCoordinates? ToServer(NetCoordinates? coords) => SEntMan.GetCoordinates(coords);
protected EntityCoordinates? ToClient(NetCoordinates? coords) => CEntMan.GetCoordinates(coords);
protected NetEntity FromServer(EntityUid suid) => SEntMan.GetNetEntity(suid);
protected NetEntity FromClient(EntityUid cuid) => CEntMan.GetNetEntity(cuid);
protected NetEntity? FromServer(EntityUid? suid) => SEntMan.GetNetEntity(suid);
protected NetEntity? FromClient(EntityUid? cuid) => CEntMan.GetNetEntity(cuid);
protected NetCoordinates FromServer(EntityCoordinates scoords) => SEntMan.GetNetCoordinates(scoords);
protected NetCoordinates FromClient(EntityCoordinates ccoords) => CEntMan.GetNetCoordinates(ccoords);
protected NetCoordinates? FromServer(EntityCoordinates? scoords) => SEntMan.GetNetCoordinates(scoords);
protected NetCoordinates? FromClient(EntityCoordinates? ccoords) => CEntMan.GetNetCoordinates(ccoords);
#endregion
#region Metadata & Transforms