XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
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<string, object> Handshake => new()
    {
        ["schema"] = 1, ["name"] = "XFEEDToolBox.Navigation", ["verified"] = true,
        ["gameSha256"] = NativeSystemLocationReader.GameSha256,
        ["commerceDockedReadiness"] = true, ["cgCommodityBatches"] = true
    };
    private static bool Ready(Dictionary<string, object> 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));
    }
}