From 43b8db6bcd3a4c29df998c107517d56b3e468c06 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 12 Oct 2026 04:52:27 +0200 Subject: [PATCH] LootTests: the pickup test uses a two-bay station and a non-stacking item Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/LootTests.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/LootTests.cs b/tests/Aetheria.Shared.Tests/LootTests.cs index 510813007..3c5ccd057 100644 --- a/tests/Aetheria.Shared.Tests/LootTests.cs +++ b/tests/Aetheria.Shared.Tests/LootTests.cs @@ -103,7 +103,6 @@ public sealed class LootTests : IDisposable MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000 }); cache.Upsert(new CargoBayData { Name = "Crate", Shape = new Shape(), InteriorShape = Solid(4, 4), Durability = 4 }); - cache.Upsert(new CargoBayData { Name = "Tiny", Shape = new Shape(), InteriorShape = Solid(1, 1), Durability = 4 }); cache.Upsert(new SimpleCommodityData { Name = "Ore", Shape = Solid(1, 1), MaxStack = 100 }); cache.FlushAsync().Wait(); @@ -115,7 +114,7 @@ public sealed class LootTests : IDisposable } // A ship carrying a gun, a targeting system and a spare, with ore and a spare gun in its crate. - private static Ship Spawn(Lab lab, float3 at, string bay = "Crate", bool cargo = true) + private static Ship Spawn(Lab lab, float3 at, bool cargo = true) { var hull = lab.Items.ItemData.RefOf(lab.Items.ItemData.GetByName("Skiff")); var ship = new Ship(lab.Items, lab.Zone, new EquippableItem { Data = hull, Durability = 1000000, Lot = lab.Lot++ }, new EntitySettings()); @@ -126,7 +125,7 @@ public sealed class LootTests : IDisposable Assert.True(ship.TryFindSpace(gear, out var pos)); Assert.True(ship.TryEquip(gear, pos)); } - var crate = lab.Make(bay); + var crate = lab.Make("Crate"); Assert.True(ship.TryFindSpace(crate, out var cratePos)); Assert.True(ship.TryEquip(crate, cratePos)); if (cargo) @@ -325,23 +324,21 @@ public sealed class LootTests : IDisposable public void TryPickUpStoresAndRemoves() { var lab = Build(); - var taker = Spawn(lab, float3(0, 0, 0), bay: "Tiny", cargo: false); - var big = lab.Make("Crate"); - Assert.Contains(Solid(5, 5).AllCoordinates, cell => taker.TryEquip(big, cell)); + var taker = Station(lab, float3(0, 0, 0)); + Assert.True(taker.TryEquip(lab.Make("Crate"), new int2(2, 2))); Assert.Equal(2, taker.CargoBays.Count); + // The first bay is full, so the first bay that accepts the item is the second. + while (taker.CargoBays[0].TryStore(lab.Make("Spare"))) { } var removals = 0; using var sub = lab.Zone.FloatingItems.ObserveRemove().Subscribe(_ => removals++); - var ore = lab.Ore(5); - var floating = lab.Zone.Release(ore, new float2(1, 2), new float2(3, 4)); - - // The one-cell bay is full, so the first bay that accepts the ore is the second. - Assert.True(taker.CargoBays[0].TryStore(lab.Make("Spare"))); + var item = lab.Make("Spare"); + var floating = lab.Zone.Release(item, new float2(1, 2), new float2(3, 4)); Assert.True(lab.Zone.TryPickUp(taker, floating.Id)); Assert.Equal(1, removals); Assert.Empty(lab.Zone.FloatingItems); - Assert.Contains(ore, taker.CargoBays[1].Cargo.Keys); - Assert.DoesNotContain(ore, taker.CargoBays[0].Cargo.Keys); + Assert.Contains(item, taker.CargoBays[1].Cargo.Keys); + Assert.DoesNotContain(item, taker.CargoBays[0].Cargo.Keys); // The same id again is unknown now. Assert.False(lab.Zone.TryPickUp(taker, floating.Id));