Signal Assertions
An Assertion Tool to verify for emitted signals until a certain time. When the timeout is reached, the assertion fails with a timeout error. The default timeout of 2s can be overridden by wait_until(
-
GdUnitSignalAssert
Function Description is_emitted Verifies that given signal is emitted until waiting time. is_not_emitted Verifies that given signal is NOT emitted until waiting time. is_signal_exists Verifies if the signal exists on the emitter. wait_until Sets the assert signal timeout in ms. -
ISignalAssert
Function Description IsEmitted Verifies that given signal is emitted until waiting time. IsNotEmitted Verifies that given signal is NOT emitted until waiting time. IsSignalExists Verifies if the signal exists on the emitter.
Signal Assert Examples
is_emitted
Waits until the given signal is emitted or the timeout occures and fails
-
func assert_signal(<instance :Object>).is_emitted(<signal_name>, [args :Array]) -> GdUnitSignalAssert
# waits until the signal "door_opened" is emitted by the instance or fails after default timeout of 2s yield(assert_signal(instance).is_emitted("door_opened"), "completed")
-
public Task<ISignalAssert> IsEmitted(string signal, params object[] args);
// waits until the signal "door_opened" is emitted by the instance or fails after default timeout of 2s await AssertSignal(instance).IsEmitted("door_opened"); // waits until the signal "door_opened" is emitted by the instance or fails after given timeout of 200ms await AssertSignal(instance).IsEmitted("door_opened").WithTimeout(200);
is_not_emitted
Waits until the specified timeout to check if the signal was NOT emitted
-
func assert_signal(<instance :Object>).is_not_emitted(<signal_name>, [args :Array]) -> GdUnitSignalAssert
# waits until 2s and verifies the signal "door_locked" is not emitted yield(assert_signal(instance).is_not_emitted("door_locked"), "completed")
-
public Task<ISignalAssert> IsNotEmitted(string signal, params object[] args);
// waits until 2s and verifies the signal "door_locked" is not emitted await AssertSignal(instance).IsNotEmitted("door_locked"); // waits until 200ms and verifies the signal "door_locked" is not emitted await AssertSignal(instance).IsNotEmitted("door_locked").WithTimeout(200);
is_signal_exists
Verifies if the signal exists on the emitter.
-
func assert_signal(<instance :Object>).wait_until(<timeout>) -> GdUnitSignalAssert
# verify the signal 'visibility_changed' exists in the node assert_signal(node).is_signal_exists("visibility_changed");
-
public ISignalAssert IsSignalExists(string signal);
// verify the signal 'visibility_changed' exists in the node AssertSignal(node).IsSignalExists("visibility_changed");
wait_until
Sets the timeout in ms to wait.
-
func assert_signal(<instance :Object>).wait_until(<timeout>) -> GdUnitSignalAssert
# waits until 5s the signal "door_closed" is emitted or fail yield(assert_signal(instance).wait_until(5000).is_emitted("door_closed"), "completed")
-
public static async Task<ISignalAssert> WithTimeout(this Task<ISignalAssert> task, int timeoutMillis);
// waits until 5s and verifies the signal "door_locked" is not emitted or fail await AssertSignal(instance).IsEmitted("door_closed").WithTimeout(5000);