Class FramePump
Frame-pumping waits for [UnityTest] coroutines, bounded by a wall-clock budget.
Inherited Members
Namespace: Serenity.Tests.Shared
Assembly: Tests.dll
Syntax
public static class FramePump
Remarks
A frame COUNT is not a time budget, and spending one as if it were is what made four dispatch tests fail headless while passing in the editor. Work that costs wall-clock time — a thread-pool round trip, I/O, a Task continuation — needs a wall-clock budget. Interactively 120 frames is roughly two seconds, so such work always fit. Batchmode runs without vsync, so the same 120 frames can elapse in a few milliseconds and the assert fires before perfectly healthy work has had any chance to come back.
None of these helpers assert. Whether a spent budget is a failure depends on what was being waited for, so every caller waiting for something that MUST happen asserts on it immediately after the wait: a bounded wait with no assert reports success without having verified anything.
Methods
Frames(int)
Pumps exactly count frames.
Declaration
public static IEnumerator Frames(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | How many frames to pump. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Remarks
The deliberate counterpart to the bug this class exists to prevent, and the only sanctioned way to count frames in a wait: use it when the frame IS the unit, because what is being waited for is scheduled per frame rather than by the clock. Anything that costs wall-clock time takes UntilCompleted(Task, double) or Until(Func<bool>, double) instead.
Until(Func<bool>, double)
Pumps frames until condition holds or the budget elapses.
Declaration
public static IEnumerator Until(Func<bool> condition, double budgetSeconds = 10)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<bool> | condition | Evaluated once per frame, on the main thread. |
| double | budgetSeconds | Wall-clock ceiling on the wait. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
UntilCompleted(Task, double)
Pumps frames until task completes or the budget elapses.
Declaration
public static IEnumerator UntilCompleted(Task task, double budgetSeconds = 10)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | task | The task to wait for. |
| double | budgetSeconds | Wall-clock ceiling on the wait. |
Returns
| Type | Description |
|---|---|
| IEnumerator |