A game about forced loneliness, made by TACStudios
1using System;
2using NUnit.Framework.Constraints;
3
4namespace UnityEngine.TestTools.Constraints
5{
6 /// <summary>
7 /// An NUnit test constraint class to test whether a given block of code makes any GC allocations.
8 /// </summary>
9 public static class ConstraintExtensions
10 {
11 /// <summary>
12 /// Use this with NUnit's Assert.That() method to make assertions about the GC behaviour of your code. The constraint executes the delegate you provide, and checks if it caused any GC memory to be allocated. If any GC memory was allocated, the constraint passes; otherwise, the constraint fails.
13 /// See https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/api/UnityEngine.TestTools.Constraints.AllocatingGCMemoryConstraint.html for an example.
14 /// </summary>
15 /// <param name="chain"></param>
16 /// <returns></returns>
17 public static AllocatingGCMemoryConstraint AllocatingGCMemory(this ConstraintExpression chain)
18 {
19 var constraint = new AllocatingGCMemoryConstraint();
20 chain.Append(constraint);
21 return constraint;
22 }
23 }
24}