summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md
downloadProject-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2
Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md')
-rw-r--r--Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md b/Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md
new file mode 100644
index 0000000..bbf4bbb
--- /dev/null
+++ b/Library/PackageCache/com.unity.test-framework@1.1.11/Documentation~/reference-custom-constraints.md
@@ -0,0 +1,31 @@
+# Custom constraints
+
+`NUnit` allows you to write test assertions in a more descriptive and human readable way using the [Assert.That](https://github.com/nunit/docs/wiki/Assertions) mechanism, where the first parameter is an object under test and the second parameter describes conditions that the object has to meet.
+
+## Is
+
+We’ve extended `NUnit` API with a custom constraint type and declared an overlay `Is` class. To resolve ambiguity between the original implementation and the custom one you must explicitly declare it with a using statement or via addressing through the full type name `UnityEngine.TestTools.Constraints.Is`.
+
+### Static Methods
+
+| Syntax | Description |
+| -------------------- | ------------------------------------------------------------ |
+| `AllocatingGCMemory` | A constraint type that invokes the delegate you provide as the parameter of `Assert.That` and checks whether it causes any GC memory allocations. It passes if any GC memory is allocated and fails if not. |
+
+## Example
+
+```c#
+using Is = UnityEngine.TestTools.Constraints.Is;
+
+class MyTestClass
+{
+ [Test]
+ public void MyTest()
+ {
+ Assert.That(() => {
+ var i = new int[500];
+ }, Is.AllocatingGCMemory());
+ }
+}
+```
+