Boss fixtures: ordinary hulls only as the copied "like" hull; refusal tests copy a design by its runtime type
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fc992f5abe
commit
6463e79317
2 changed files with 7 additions and 5 deletions
|
|
@ -125,19 +125,21 @@ public sealed class LoadoutCommitCommandTests : IDisposable
|
|||
var fit = Fit();
|
||||
var canary = "Canary9c1e";
|
||||
var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(HullData).Assembly);
|
||||
T Copy<T>(T document) => MessagePack.MessagePackSerializer.Deserialize<T>(MessagePack.MessagePackSerializer.Serialize(document, options), options);
|
||||
object Copy(object document) => MessagePack.MessagePackSerializer.Deserialize(document.GetType(), MessagePack.MessagePackSerializer.Serialize(document.GetType(), document, options), options);
|
||||
using (var cache = Open())
|
||||
{
|
||||
// Under a key of its own, so the copy is a second record of the same name, not the first overwritten.
|
||||
void Add(object document) => Assert.True(cache.Commit(batch => batch.Upsert(document.GetType(), document, new CultRecordKey("duplicate:" + Guid.NewGuid().ToString("N")))));
|
||||
switch (refusal)
|
||||
{
|
||||
case "ambiguous-hull-product":
|
||||
cache.Upsert(Copy(cache.GetAll<FactionProductData>().Single(p => p.Name == fit.hullProduct)));
|
||||
Add(Copy(cache.GetAll<FactionProductData>().Single(p => p.Name == fit.hullProduct)));
|
||||
break;
|
||||
case "ambiguous-design":
|
||||
cache.Upsert(Copy(cache.GetAll<EquippableItemData>().Single(d => d.Name == fit.designName)));
|
||||
Add(Copy(cache.GetAll<EquippableItemData>().Single(d => d.Name == fit.designName)));
|
||||
break;
|
||||
case "mod-design":
|
||||
var mod = Copy(cache.GetAll<EquippableItemData>().Single(d => d.Name == fit.designName));
|
||||
var mod = (EquippableItemData) Copy(cache.GetAll<EquippableItemData>().Single(d => d.Name == fit.designName));
|
||||
mod.Name = "Mod gadget";
|
||||
Assert.True(cache.Commit(batch => batch.Upsert(mod.GetType(), mod, new CultRecordKey("mod-ship:mod.gadget"))));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public sealed partial class RunStartTests
|
|||
private HullData[] SoldShipHulls() => _cache.GetAll<FactionProductData>()
|
||||
.Where(product => product.Manufacturer.IsSet())
|
||||
.Select(product => _cache.Get(product.Design) as HullData)
|
||||
.Where(hull => hull != null && hull.HullType == HullType.Ship && hull.Price > 0)
|
||||
.Where(hull => hull != null && hull.HullType == HullType.Ship && hull.Price > 0 && !hull.Boss)
|
||||
.Distinct().ToArray();
|
||||
|
||||
// A Boss hull a faction makes, by the production path: a copy of a sold ship hull (so it builds into a real ship) flagged
|
||||
|
|
|
|||
Loading…
Reference in a new issue