using System;using System.Linq;using System.Reflection;using NUnit.Framework;using UnityEngine;using DevilLink2.UI;using DevilLink2.Core;using DevilLink2.Gameplay; namespace DevilLink2.Tests {public sealed partial class UIScreenTests { private void GlobalClear(){var f=bootstrap.Flow;var finder=new BoardMoveFinder();int limit=f.Runtime.Session.Board.RemainingTileCount/2;for(int i=0;i(true).Length;for(int i=0;i<5;i++){open[index]();open[index]();Assert.That(screens[index].IsVisible,Is.True);Assert.That(ui.Lobby.GetComponent().interactable,Is.False);close[index]();Assert.That(screens[index].gameObject.activeSelf,Is.False);Assert.That(ui.Lobby.GetComponent().interactable,Is.True);}Assert.That(ui.GetComponentsInChildren(true).Length,Is.EqualTo(count));Assert.That(root.GetComponentsInChildren(true).Length,Is.EqualTo(1));} [TestCase(GameMode.Classic)][TestCase(GameMode.TimeAttack)][TestCase(GameMode.Zen)]public void GlobalVictoryUpdatesOnlyItsModeAndLobby(GameMode mode){ui.ShowLobby();ui.SelectMode(mode);int level=bootstrap.Session.Definition.Level;var other=Enum.GetValues(typeof(GameMode)).Cast().Where(m=>m!=mode).ToArray();var values=other.Select(m=>player.Progress.GetHighestCleared(m)).ToArray();GlobalClear();ui.Hud.Result.LobbyButton.onClick.Invoke();Assert.That(ui.CurrentPage,Is.EqualTo(UIPage.Lobby));Assert.That(player.Progress.GetHighestCleared(mode),Is.EqualTo(level));Assert.That(ui.Lobby.Cards[(int)mode].ProgressLabel.text,Does.Contain("CLEARED "+level+"/20"));for(int i=0;i(true).Length,Is.EqualTo(1));}finally{sound.Close();}} [Test]public void GlobalRepeatedInitializeDoesNotAddEconomySubscribers(){var field=typeof(PlayerEconomy).GetField("PersistentStateChanged",BindingFlags.NonPublic|BindingFlags.Instance);int before=((Delegate)field.GetValue(player.Economy)).GetInvocationList().Length;for(int i=0;i<5;i++){ui.Initialize(player,bootstrap);ui.ShowLobby();ui.OpenShop();ui.CloseShop();}Assert.That(((Delegate)field.GetValue(player.Economy)).GetInvocationList().Length,Is.EqualTo(before));} }}