Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ConstraintsExtensions.cs 1.1KB

123456789101112131415161718192021222324
  1. using System;
  2. using NUnit.Framework.Constraints;
  3. namespace UnityEngine.TestTools.Constraints
  4. {
  5. /// <summary>
  6. /// An NUnit test constraint class to test whether a given block of code makes any GC allocations.
  7. /// </summary>
  8. public static class ConstraintExtensions
  9. {
  10. /// <summary>
  11. /// 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.
  12. /// See https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/api/UnityEngine.TestTools.Constraints.AllocatingGCMemoryConstraint.html for an example.
  13. /// </summary>
  14. /// <param name="chain"></param>
  15. /// <returns></returns>
  16. public static AllocatingGCMemoryConstraint AllocatingGCMemory(this ConstraintExpression chain)
  17. {
  18. var constraint = new AllocatingGCMemoryConstraint();
  19. chain.Append(constraint);
  20. return constraint;
  21. }
  22. }
  23. }