using System.Text.Json; using XFEEDToolBox.Core.Execution; using XFEEDToolBox.Core.Native; using XFEExtension.NetCore.XUnit.Attributes; namespace XFEEDToolBox.Test; [TestFixture] public class NativeTradeCapabilitiesTests { private static Dictionary Handshake => new() { ["schema"] = 1, ["name"] = "XFEEDToolBox.Navigation", ["verified"] = true, ["gameSha256"] = NativeSystemLocationReader.GameSha256, ["commerceDockedReadiness"] = true, ["cgCommodityBatches"] = true }; private static bool Ready(Dictionary value) => NativeTradeCapabilities.SupportsDockedTrade(JsonSerializer.SerializeToElement(value)); [Test] public void VerifiedNativeCapabilitiesEnableTradeWithoutTheLegacyManifestFlag() => Check.Equal(true, Ready(Handshake)); [Test] public void AnUnverifiedInterfaceCannotEnableExecution() { var value = Handshake; value["verified"] = false; Check.Equal(false, Ready(value)); } [Test] public void AnotherGameBuildCannotEnableExecution() { var value = Handshake; value["gameSha256"] = new string('0', 64); Check.Equal(false, Ready(value)); } [Test] public void MissingBatchCapabilityCannotEnableExecution() { var value = Handshake; value.Remove("cgCommodityBatches"); Check.Equal(false, Ready(value)); } [Test] public void MissingDockedReadinessCannotEnableExecution() { var value = Handshake; value["commerceDockedReadiness"] = false; Check.Equal(false, Ready(value)); } [Test] public void AStringInsteadOfACapabilityIsNotAccepted() { var value = Handshake; value["cgCommodityBatches"] = "true"; Check.Equal(false, Ready(value)); } [Test] public void DockedCommerceAloneCannotStartAProductionFlight() { try { NativeTradeCapabilities.RequireProductionFlight(JsonSerializer.SerializeToElement(Handshake)); } catch (NotSupportedException) { return; } throw new InvalidOperationException("The original flight prerequisites were bypassed."); } [Test] public void ProductionFlightRequiresBothOriginalControlCapabilities() { var value = Handshake; value["supercruiseOverchargeControl"] = true; value["interdictionEscapeControl"] = true; NativeTradeCapabilities.RequireProductionFlight(JsonSerializer.SerializeToElement(value)); } }