using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using NUnit.Framework; using TMPro; using UnityEngine; using UnityEngine.TestTools; using UnityEngine.UI; using Object=UnityEngine.Object; namespace HexaCrazy.Tests { public class MotionFeedbackTests { HexGameApp app;string folder;int source,target,drop; [UnitySetUp] public IEnumerator Setup() { folder=Path.Combine(Path.GetTempPath(),"HexaCrazyMotionTests",Guid.NewGuid().ToString("N")); app=new GameObject("MotionTestApp").AddComponent();app.UseReviewProfile(Path.Combine(folder,"save.json")); app.Profile.Data.reduceMotion=false;app.Profile.Data.tutorial=1; if(Object.FindAnyObjectByType()==null)app.gameObject.AddComponent(); app.GetComponent().Music=false;app.GetComponent().Sound=false; yield return new WaitForSecondsRealtime(.95f); } [UnityTearDown] public IEnumerator Cleanup(){Object.Destroy(app.gameObject);yield return null;if(Directory.Exists(folder))Directory.Delete(folder,true);} void Fixture(int center=3,int mode=0) { app.StartLevel(mode,1,true);foreach(var c in app.Game.Cells){c.tiles.Clear();c.need=0;} source=Index(-1,0);target=Index(0,0);drop=Index(1,0); app.Game.Cells[source].tiles.AddRange(new[]{1,1,0,0,0});app.Game.Cells[target].tiles.AddRange(Enumerable.Repeat(0,center)); app.Game.Hand[0]=new HandGroup(0,1);app.SelectHand(0); } int Index(int q,int r)=>app.Game.Cells.FindIndex(c=>c.q==q&&c.r==r); HexStackView View(int cell)=>app.Root.GetComponentsInChildren().First(v=>v.CellIndex==cell); IEnumerator Until(Func condition,float timeout=5) { float end=Time.realtimeSinceStartup+timeout;while(!condition()&&Time.realtimeSinceStartup