Class TestUtils
Unity test utilities.
Namespace: nickmaltbie.TestUtilsUnity.Tests.TestCommon
Assembly: cs.temp.dll.dll
Syntax
public static class TestUtils
Methods
AssertInBounds(Single, Single, Single, String, TestUtils.BoundRange)
Assert that a float value is within a specific bound.
Declaration
public static void AssertInBounds(float actual, float expected, float range = 0.001F, string errorMsg = null, TestUtils.BoundRange bound = TestUtils.BoundRange.GraterThanOrLessThan)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | actual | Actual value. |
| Single | expected | Expected value. |
| Single | range | Acceptable range of error. |
| String | errorMsg | Error message to log if failure, one will be generated if none is provided. |
| TestUtils.BoundRange | bound | Allow the actual value to be lesser, grater, or either. |
AssertInBounds(Vector3, Vector3, Single, String, TestUtils.BoundRange)
Assert that two vectors are within a specific bound of each other.
Declaration
public static void AssertInBounds(Vector3 actual, Vector3 expected, float range = 0.001F, string errorMsg = null, TestUtils.BoundRange bound = TestUtils.BoundRange.GraterThanOrLessThan)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | actual | Actual vector found. |
| Vector3 | expected | Expected vector to find. |
| Single | range | Range in units of acceptable error. |
| String | errorMsg | Error message to log if failure, one will be generated if none is provided. |
| TestUtils.BoundRange | bound | Allow the actual vector to be shorter, longer, or either. |
WaitUntil(Func<Boolean>, Object, Int32)
Wait until a condition is meet.
Declaration
public static IEnumerator WaitUntil(Func<bool> verify, object toYield, int times)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Boolean> | verify | What needs to be verified. |
| Object | toYield | Event to yield. |
| Int32 | times | Number of times to yield iterator. |
Returns
| Type | Description |
|---|---|
| IEnumerator | Iterator of events. |
WaitUntil(Func<Boolean>, Single, Int32)
Wait until a condition is met for a given number of seconds.
Declaration
public static IEnumerator WaitUntil(Func<bool> verify, float waitInterval = 0.1F, int iterations = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Boolean> | verify | What needs to be verified. |
| Single | waitInterval | Wait interval in seconds. |
| Int32 | iterations | Number of intervals to wait for. |
Returns
| Type | Description |
|---|---|
| IEnumerator | Iterator of events. |