Cargo transfer tests: long steps after the receiver leaves or strays move nothing; a full first bay hands on to the next

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-22 19:56:54 +02:00
commit dadb6f327d

View file

@ -31,6 +31,9 @@ public sealed class CargoTransferTests : IDisposable
foreach (var cell in pocket.AllCoordinates) pocket[cell] = true;
_cache.Upsert(new CargoBayData { Name = "Pocket", Shape = new Shape(), InteriorShape = pocket, Price = 5, Durability = 4 });
_cache.Upsert(new SimpleCommodityData { Name = "Ore", Shape = new Shape(), Price = 7, MaxStack = 100 });
var bin = new Shape(1, 1);
bin[0, 0] = true;
_cache.Upsert(new CargoBayData { Name = "Bin", Shape = bin, InteriorShape = bin, Price = 5, Durability = 4 });
_cache.Upsert(new SimpleCommodityData { Name = "Grit", Shape = new Shape(), Price = 1, MaxStack = 2 });
_cache.Upsert(new SimpleCommodityData { Name = "Slag", Shape = new Shape(), Price = 1, MaxStack = 100 });
_cache.Upsert(new DockingBayData { Name = "Berth", Shape = new Shape(), InteriorShape = bay, MaxSize = new int2(2, 2), Price = 60, Durability = 6 });
@ -284,6 +287,51 @@ public sealed class CargoTransferTests : IDisposable
Assert.True(receiver.CargoBays[0].Cargo.ContainsKey(gun));
}
[Fact]
public void ALongStepAfterTheReceiverLeavesMovesNothing()
{
var (giver, receiver, ore) = Alongside(10);
giver.Command.Give(receiver, ore, 10);
Steps(1);
_zone.Remove(receiver);
_zone.Update(5f);
Assert.Equal(0, Held(receiver, ore));
Assert.Equal(10, Held(giver, ore));
Assert.Equal(GiveEnd.ReceiverGone, giver.LastGiveEnd);
}
[Fact]
public void ALongStepOutOfRangeMovesNothing()
{
var (giver, receiver, ore) = Alongside(10);
giver.Command.Give(receiver, ore, 10);
Steps(1);
receiver.Position = giver.Position + new float3(0, 0, _items.GameplaySettings.DockingDistance + 1);
_zone.Update(5f);
Assert.Equal(0, Held(receiver, ore));
Assert.Equal(GiveEnd.OutOfRange, giver.LastGiveEnd);
}
[Fact]
public void AGiveGoesToTheNextReceiverBayWhenTheFirstIsFull()
{
var (giver, receiver, ore) = Alongside(10, "Bin");
Assert.True(receiver.CargoBays[0].TryStore(Commodity("Slag", 5)));
Assert.True(receiver.TryEquip(Mint("Crate")));
Assert.Equal(2, receiver.CargoBays.Count);
giver.Command.Give(receiver, ore, 3);
Steps(40);
Assert.Equal(0, Units(receiver.CargoBays[0], ore));
Assert.Equal(3, Units(receiver.CargoBays[1], ore));
Assert.Equal(GiveEnd.Done, giver.LastGiveEnd);
}
[Fact]
public void GiveRangeIsMeasuredOnTheFlatPlane()
{