暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ConstraintsExtensions.cs 1.1KB

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