docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Is

    NUnit allows you to write test assertions in a more descriptive and human readable way using the Assert.That mechanism, where the first parameter is an object under test and the second parameter describes conditions that the object has to meet.

    We have extended NUnit API with a custom constraint type and declared an overlay Is class. To resolve ambiguity between the original implementation and the custom one you must explicitly declare it with a using statement or via addressing through the full type name UnityEngine.TestTools.Constraints.Is.

    Inheritance
    object
    Is
    Is
    Inherited Members
    Is.EqualTo(object)
    Is.SameAs(object)
    Is.GreaterThan(object)
    Is.GreaterThanOrEqualTo(object)
    Is.AtLeast(object)
    Is.LessThan(object)
    Is.LessThanOrEqualTo(object)
    Is.AtMost(object)
    Is.TypeOf(Type)
    Is.TypeOf<TExpected>()
    Is.InstanceOf(Type)
    Is.InstanceOf<TExpected>()
    Is.AssignableFrom(Type)
    Is.AssignableFrom<TExpected>()
    Is.AssignableTo(Type)
    Is.AssignableTo<TExpected>()
    Is.EquivalentTo(IEnumerable)
    Is.SubsetOf(IEnumerable)
    Is.SupersetOf(IEnumerable)
    Is.StringContaining(string)
    Is.StringStarting(string)
    Is.StringEnding(string)
    Is.StringMatching(string)
    Is.SamePath(string)
    Is.SubPathOf(string)
    Is.SamePathOrUnder(string)
    Is.InRange(IComparable, IComparable)
    Is.Not
    Is.All
    Is.Null
    Is.True
    Is.False
    Is.Positive
    Is.Negative
    Is.Zero
    Is.NaN
    Is.Empty
    Is.Unique
    Is.BinarySerializable
    Is.XmlSerializable
    Is.Ordered
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.TestTools.Constraints
    Assembly: UnityEngine.TestRunner.dll
    Syntax
    public class Is : Is

    Methods

    AllocatingGCMemory()

    A constraint type that invokes the delegate you provide as the parameter of Assert.That and checks whether it causes any GC memory allocations.

    Declaration
    public static AllocatingGCMemoryConstraint AllocatingGCMemory()
    Returns
    Type Description
    AllocatingGCMemoryConstraint

    An AllocationGCMemoryConstrain.

    Examples
    using Is = UnityEngine.TestTools.Constraints.Is;
    
    class MyTestClass
    {
        [Test]
        public void MyTest()
        {
            Assert.That(() => {
            var i = new int[500];
            }, Is.AllocatingGCMemory());
        }
    }
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)