using NUnit.Framework; using System.Collections; using UnityEngine; using UnityEngine.TestTools; namespace Funique.Test { public sealed partial class ManagerTest { /// /// Testing the utility functionality
/// ------------------------------------------------
/// 測試幫助元件功能 ///
public sealed class CoroutineHelperTest { GameObject g; CoroutineHelper helper; bool done = false; float t; [OneTimeSetUp] public void Setup() { g = new GameObject(); helper = g.AddComponent(); done = false; } [OneTimeTearDown] public void TearDown() { GameObject.Destroy(g); } [UnityTest] public IEnumerator AsyncTest() { t = Time.time; helper.Run(Wait()); yield return new WaitUntil(() => done || Time.time > t + 5f); Assert.IsTrue(done, "Coroutine run failed"); } private IEnumerator Wait() { yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame(); done = true; } } } }