PiratesFactionCommandTests: flush the name-file removal; tolerate a null empty role list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-08 19:39:54 +02:00
commit 8e51016f23

View file

@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
@ -102,7 +103,7 @@ public sealed class PiratesFactionCommandTests : IDisposable
var design = (CraftedItemData) db.Cache.Get(product.Design);
Assert.Equal(designName, design.Name);
Assert.Equal(description, product.Description);
Assert.Equal(design.Roles.Select(role => role.Name), product.Roles.Select(role => role.Role));
Assert.Equal((design.Roles ?? new List<ItemRole>()).Select(role => role.Name), (product.Roles ?? new List<ProductRole>()).Select(role => role.Role));
Assert.All(product.Roles, role => { Assert.Equal(.45f, role.Mean); Assert.Equal(.22f, role.StandardDeviation); });
}
}
@ -145,6 +146,7 @@ public sealed class PiratesFactionCommandTests : IDisposable
var db = AetherDb.Open(catalogWritable: true, root: _root);
var pleiades = db.Cache.GetAll<NameFile>().Single(file => file.Name == "pleiades");
Assert.True(db.Cache.Remove(db.Cache.RefOf(pleiades).Key));
db.Cache.FlushAsync().Wait();
db.Cache.Dispose();
Assert.Throws<InvalidOperationException>(() => Program.PiratesFaction(apply: true, root: _root));