public static void Beacon <BEACONTYPE>(BEACONTYPE beacon, E7.Minefield.BeaconConstraint bc) where BEACONTYPE : Enum { var result = bc.ApplyToBeacon(beacon); if (result.IsSuccess == false) { Assert.Fail(result.Description); } }
// public sealed class ThrowableWaitUntil : IEnumerator // { // Func<bool> m_Predicate; // public ThrowableWaitUntil(Func<bool> predicate) { m_Predicate = predicate; } // public object Current => null; // public bool MoveNext() // { // try // { // } // } // public void Reset() {} // } /// <summary> /// Remember that base condition for all constraints is that the beacon must be found, /// and to be found the game object must be active. /// /// It will not fail the test if the constraint doesn't happen yet, /// please check manually if you really have that type of /// beacon in the scene or it would wait forever when you actually forgot to add the beacon. /// (Unlike assertion where you immediately get /// an error message telling you about missing beacon.) /// </summary> public static IEnumerator WaitUntil <T>(T beacon, BeaconConstraint bc) where T : Enum { // Debug.Log($"Wait until {Time.frameCount} {bc}"); // yield return new WaitUntil(() => bc.ApplyToBeacon(beacon).IsSuccess); //Debug.Log($"Wait until {Time.frameCount} {bc} {bc.ApplyToBeacon(beacon).IsSuccess}"); while (true) { try { if (bc.ApplyToBeacon(beacon).IsSuccess) { break; } } catch (Exception e) { Debug.Log($"Caught sometihing >>> {e}"); throw; } yield return(null); } //Debug.Log($"Wait ok {Time.frameCount}"); }
/// <summary> /// Just check if the constraint passed or not, without affecting failing/passing of the test. /// </summary> public static bool Check <T>(T beacon, BeaconConstraint bc) where T : Enum => bc.ApplyToBeacon(beacon).IsSuccess;