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

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
using Newtonsoft.Json.Linq;
using XFEWarframe.Core;
using XFEWarframe.Core.Data;
using XFEWarframe.Core.Services;
using Xunit;

namespace XFEWarframe.Tests;

public sealed partial class EngineTests
{
    [Fact] public async Task CircuitSelectionSurvivesRetriesAndMissionClaimsResetNextWeek()
    {
        var time = new TestClock(new DateTimeOffset(2026, 9, 24, 12, 0, 0, TimeSpan.Zero)); engine = new(store, options, time); var q = await Login();
        var choice = WorldRotations.CircuitChoices(WorldData.WeekOf(time.Now.ToUnixTimeMilliseconds()), GameVersion.Parse(options.FallbackBuildLabel))[0]!["Choices"]![0]!.ToString();
        var selection = new { Mode = "r", Category = "EXC_NORMAL", Choices = new[] { choice } }; var first = await Call("/api/endlessXp.php", selection, q); Assert.True(first.Status == 200, first.Body); Assert.Equal(first.Body, (await Call("/api/endlessXp.php", selection, q)).Body);
        var mission = new { EndOfMatchUpload = true, MissionStatus = "GS_SUCCESS", Missions = new { Tag = "SolNode238", Tier = 0, Completes = 1 }, RewardInfo = new { node = "SolNode238", rewardSeed = "7", rewardQualifications = new[] { "1", "2", "3", "4" } } };
        var completion = await Call("/api/missionInventoryUpdate.php", mission, q); Assert.True(completion.Status == 200, completion.Body); Assert.Equal(completion.Body, (await Call("/api/missionInventoryUpdate.php", mission, q)).Body);
        Assert.Equal(530, (await InventoryOf(q))["EndlessXP"]![0]!.Value<int>("Earn")); Assert.Equal(200, (await Call("/api/endlessXp.php", selection, q)).Status); Assert.Equal(530, (await InventoryOf(q))["EndlessXP"]![0]!.Value<int>("Earn"));
        var claim = await Call("/api/endlessXp.php", new { Mode = "c", Category = "EXC_NORMAL" }, q); Assert.True(claim.Status == 200, claim.Body); var before = await InventoryOf(q); Assert.NotEmpty(JObject.Parse(claim.Body)["InventoryChanges"]!);
        Assert.Empty(JObject.Parse((await Call("/api/endlessXp.php", new { Mode = "c", Category = "EXC_NORMAL" }, q)).Body)["InventoryChanges"]!); Assert.True(JToken.DeepEquals(before, await InventoryOf(q)));
        time.Now = time.Now.AddDays(7); Assert.Equal(409, (await Call("/api/endlessXp.php", new { Mode = "c", Category = "EXC_NORMAL" }, q)).Status);
        choice = WorldRotations.CircuitChoices(WorldData.WeekOf(time.Now.ToUnixTimeMilliseconds()), GameVersion.Parse(options.FallbackBuildLabel))[0]!["Choices"]![0]!.ToString(); Assert.Equal(200, (await Call("/api/endlessXp.php", new { Mode = "r", Category = "EXC_NORMAL", Choices = new[] { choice } }, q)).Status); Assert.Equal(0, (await InventoryOf(q))["EndlessXP"]![0]!.Value<int>("Earn"));
    }
    [Fact] public async Task DescentAndConquestThresholdsGrantOnlyOnce()
    {
        var q = await Login(); var selected = await Call("/api/descentRewards.php", new { Mode = "r", Category = "DM_COH_NORMAL" }, q); Assert.True(selected.Status == 200, selected.Body);
        Assert.Equal(selected.Body, (await Call("/api/descentRewards.php", new { Mode = "r", Category = "DM_COH_NORMAL" }, q)).Body);
        var mission = new JObject { ["BMI"] = true, ["RewardInfo"] = new JObject { ["node"] = "SolNode000", ["missionType"] = "MT_DESCENT", ["EncounterEnemyLevel"] = 2, ["rewardSeed"] = "7" } };
        var completed = await Call("/api/missionInventoryUpdate.php", mission, q); Assert.True(completed.Status == 200, completed.Body); Assert.Single(JObject.Parse(completed.Body)["MissionRewards"]!); var before = await InventoryOf(q); mission["RewardInfo"]!["rewardSeed"] = "8";
        Assert.Empty(JObject.Parse((await Call("/api/missionInventoryUpdate.php", mission, q)).Body)["MissionRewards"]!); Assert.True(JToken.DeepEquals(before, await InventoryOf(q)));
        var unlock = await Call("/api/entratiLabConquestMode.php", new { BuyMode = 1 }, q); Assert.True(unlock.Status == 200, unlock.Body); Assert.Equal(2, JObject.Parse(unlock.Body).Value<int>("EntratiVaultCountLastPeriod")); Assert.Equal(unlock.Body, (await Call("/api/entratiLabConquestMode.php", new { BuyMode = 1 }, q)).Body);
        mission["RewardInfo"] = new JObject { ["node"] = "SolNode000", ["ConquestCompleted"] = 2, ["ConquestHardModeActive"] = 1, ["ConquestPersonalModifiersActive"] = 4, ["ConquestEquipmentSuggestionsFulfilled"] = 4 };
        completed = await Call("/api/missionInventoryUpdate.php", mission, q); Assert.True(completed.Status == 200, completed.Body); Assert.Equal(8, JObject.Parse(completed.Body)["MissionRewards"]!.Count()); before = await InventoryOf(q); mission["RewardInfo"]!["rewardSeed"] = "9"; Assert.Empty(JObject.Parse((await Call("/api/missionInventoryUpdate.php", mission, q)).Body)["MissionRewards"]!); Assert.True(JToken.DeepEquals(before, await InventoryOf(q)));
    }
    [Fact] public async Task PromoCodeRejectsDuplicatesAndInvalidCodesWithoutMutation()
    {
        var q = await Login(); var code = ((JObject)Assets.Json("fixed_responses/glyphsCodes.json")).Properties().First(); var first = await Call("/api/redeemPromoCode.php", new { codeId = code.Name }, q); Assert.True(first.Status == 200, first.Body); Assert.NotEmpty(JObject.Parse(first.Body)["FlavourItems"]!); var before = await InventoryOf(q);
        Assert.Equal("USED_CODE", (await Call("/api/redeemPromoCode.php", new { codeId = code.Name }, q)).Body); Assert.Equal("INVALID_CODE", (await Call("/api/redeemPromoCode.php", new { codeId = "invalid-xfe-code" }, q)).Body); Assert.True(JToken.DeepEquals(before, await InventoryOf(q)));
    }
    [Fact] public async Task AssistanceRespectsExclusionsAndNeverLeaksAccountIdentityOrCredentials()
    {
        var q = await Login(); var other = await Login("operator@test.local"); await store.Update(state => { var inv = ((JObject)state["accounts"]![other["accountId"]]!).Obj("Inventory"); inv.Array("QuestKeys").Add(new JObject { ["ItemType"] = "/Lotus/Types/Keys/OrokinMoonQuest/OrokinMoonQuestKeyChain", ["Completed"] = true }); inv.Array("OperatorSuits").Add(new JObject { ["ItemType"] = "/Lotus/Powersuits/Operator/ChildOperatorSuitRemaster", ["Configs"] = new JArray(new JObject { ["marker"] = "operator-config" }) }); return 0; });
        var body = new JObject { ["MissionTag"] = "SolNode1", ["Count"] = 2, ["Candidates"] = new JArray(Wire.Oid(other["accountId"])), ["ExcludedNames"] = new JArray() };
        var result = await Call("/api/asyncMissionAssist.php", body, q); Assert.True(result.Status == 200, result.Body); Assert.Contains("operator-config", result.Body); Assert.DoesNotContain(other["accountId"], result.Body); Assert.DoesNotContain("credential", result.Body); Assert.DoesNotContain("email", result.Body);
        body["ExcludedNames"] = new JArray("operator\ue000"); result = await Call("/api/asyncMissionAssist.php", body, q); Assert.DoesNotContain("operator-config", result.Body); Assert.Equal(2, JObject.Parse(result.Body)["Results"]!.Count());
    }
    [Fact] public async Task RepeatedKahlChallengeDoesNotDuplicateStock()
    {
        var q = await Login(); await store.Update(state => { ((JObject)state["accounts"]![q["accountId"]]!).Obj("Inventory").Array("Affiliations").Add(new JObject { ["Tag"] = "KahlSyndicate", ["WeeklyMissions"] = new JArray(new JObject { ["WeekCount"] = 91, ["Challenges"] = new JArray() }) }); return 0; });
        var body = new { WeeklyMissionChallengeInfo = new[] { new { Syndicate = "KahlSyndicate", WeekCount = 91, CompletedChallenges = new[] { "/Lotus/Types/Challenges/NoDeathKahlChallenge" } } } };
        var first = await Call("/api/missionInventoryUpdate.php", body, q); Assert.True(first.Status == 200, first.Body); var before = await InventoryOf(q); Assert.Equal(200, (await Call("/api/missionInventoryUpdate.php", body, q)).Status); Assert.True(JToken.DeepEquals(before, await InventoryOf(q))); Assert.Equal(30, before["MiscItems"]!.First(x => x.Value<string>("ItemType") == "/Lotus/Types/Items/MiscItems/KahlCreds").Value<int>("ItemCount"));
    }
}