public static void RunTests(TestRunnerMode mode, Action <IEnumerator> mainThreadDispatcher, Action onEnd) { Debug.Log("start test, mode:" + mode); var testRunner = new MiyamasuTestRunner(mainThreadDispatcher, onEnd); testRunner.RunTests(); }
private IEnumerator _WaitCor(MiyamasuTestRunner runner) { while (true) { if (assert()) { // done. yield break; } if (timelimit < DateTime.Now.Ticks) { try { onTimeout(); } catch (Exception e) { runner.MarkAsTimeout(e); throw; } yield break; } yield return(null); } }
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] public static void RunTestsFromCode() { var runnerSettings = Settings.LoadSettings(); if (!runnerSettings.runOnPlay) { return; } var go = new GameObject("MiyamasuTestMainThreadRunner"); go.hideFlags = go.hideFlags | HideFlags.HideAndDontSave; var mb = go.AddComponent <MainThreadRunner>(); Action <IEnumerator> newMainThreadDispatcher = iEnum => { mb.Commit(iEnum, () => {}); }; var testRunner = new MiyamasuTestRunner( newMainThreadDispatcher, () => { // do nothing yet. } ); testRunner.RunTests(); }
public _WaitUntil(Func <bool> assert, Action onTimeout, double sec, MiyamasuTestRunner runner) { this.assert = assert; this.onTimeout = onTimeout; this.timelimit = (DateTime.Now + TimeSpan.FromSeconds(sec)).Ticks; this.t = _WaitCor(runner); }