{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} Class AllocatingGCMemoryConstraint | Test Framework | 2.0.1-exp.2
docs.unity3d.com
"{0}"의 검색 결과

    목차 표시/숨기기

    Class AllocatingGCMemoryConstraint

    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.

    Be careful to take into account that there may be GC allocations that happen only on the first time your code is run, such as initialization of static variables. If you want to measure a 'typical' execution of your code, you may want to deliberately execute it once before testing it with this constraint, so that any one-time allocations have already been performed before this constraint measures it.

    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:

    상속
    object
    AllocatingGCMemoryConstraint
    네임스페이스: UnityEngine.TestTools.Constraints
    어셈블리: solution.dll
    구문
    public class AllocatingGCMemoryConstraint : Constraint
    예
    using NUnit.Framework;
    using UnityEngine.TestTools.Constraints;
    using Is = UnityEngine.TestTools.Constraints.Is;
    
    public class MyTestClass
    {
        [Test]
        public void SettingAVariableDoesNotAllocate()
        {
            Assert.That(() => {
                int a = 0;
                a = 1;
            }, Is.Not.AllocatingGCMemory());
        }
    }

    프로퍼티

    이름 설명
    Description

    The Description of what this constraint tests, for to use in messages and in the ConstraintResult.

    메서드

    이름 설명
    ApplyTo(object)

    Applies GC memory constraint to the test.

    ApplyTo<TActual>(ActualValueDelegate<TActual>)

    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.

    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)