Is

class in UnityEngine.TestTools.Constraints

Cambiar al Manual

Descripción

Provides Unity-specific constraint types for use with NUnit's Assert.That method.

NUnit allows test authors to write assertions using the Assert.That() method, where the first parameter is the object under test, and the second parameter describes the conditions that the object has to meet. These can often be expressed in a human-readable style, for example Assert.That(3, Is.Not.EqualTo(2)).

Unity extends NUnit's mechanisms with some custom Unity-specific constraint types, and declares this "Is" class as an overlay on top of NUnit's. To resolve ambiguity between NUnit's own Is class and Unity's, you must explicitly declare it in a using statement, like this:

using NUnit.Framework;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;

class MyTestClass { [Test] public void MyTest() { Assert.That(() => { var i = new int[500]; }, Is.AllocatingGCMemory()); } }

Funciones Estáticas

AllocatingGCMemoryDeclares a constraint that the provided delegate allocates GC memory.