/// An NUnit test constraint class to test whether a given block of code makes any GC allocations.
///
/// Use this class 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 has caused any GC memory to be allocated. If any GC memory was allocated, the constraint passes; otherwise, the constraint fails.
///
/// Usually you negate this constraint to make sure that your delegate does not allocate any GC memory. This is easy to do using the Is class:
/// </summary>
/// <example>
/// <code>
/// using NUnit.Framework;
/// using UnityEngine.TestTools.Constraints;
/// using Is = UnityEngine.TestTools.Constraints.Is;
/// <exception cref="ArgumentNullException">Throws a <see cref="ArgumentNullException"/> if the provided object is null.</exception>
/// <exception cref="ArgumentException">Throws a <see cref="ArgumentException"/> if the provided object is not a <see cref="TestDelegate"/>.</exception>
publicoverrideConstraintResultApplyTo(objectobj)
{
if(obj==null)
thrownewArgumentNullException();
TestDelegated=objasTestDelegate;
if(d==null)
thrownewArgumentException(string.Format("The actual value must be a TestDelegate but was {0}",
obj.GetType()));
returnApplyTo(()=>d.Invoke(),obj);
}
/// <summary>
/// Test whether the constraint is satisfied by a given reference.
/// The default implementation simply dereferences the value but
/// derived classes may override it to provide for delayed processing.