public void Awake()
    {
        // An assertion that will compare a foat value from a custom component attached to a GameObject to a constant variable equal to 3.
        // The comparasment will happen Start method and every 5 frames in the Update method
        // Additionally, the comparer is configured to have accuracy of 0.1 for floating euqlity check.
        IAssertionComponentConfigurator configurator;
        var c = AssertionComponent.Create <FloatComparer>(out configurator, CheckMethod.Update | CheckMethod.Start, gameObject, "CodeBasedAssertionExample.FloatField", 3f);

        configurator.UpdateCheckRepeatFrequency = 5;
        c.floatingPointError = 0.1;
        c.compareTypes       = FloatComparer.CompareTypes.Equal;

        // Create an assertion that will fail is the FloatField from InitAssertions component of gameObject will change it's value
        AssertionComponent.Create <ValueDoesNotChange>(CheckMethod.Update | CheckMethod.Start, gameObject, "CodeBasedAssertionExample.FloatField");

        // Validate the gameObject.transform.y is always equal to 3 (defined in this component)
        transform.position = new Vector3(0, 3, 0);
        AssertionComponent.Create <FloatComparer>(CheckMethod.Update, gameObject, "CodeBasedAssertionExample.FloatField", gameObject, "transform.position.y");

        // Check with the goReference field from this component is not set to null
        goReference = gameObject;
        var gc = AssertionComponent.Create <GeneralComparer>(CheckMethod.Update, gameObject, "CodeBasedAssertionExample.goReference", null);

        gc.compareType = GeneralComparer.CompareType.ANotEqualsB;
    }
示例#2
0
        /// <summary>
        /// Invokes the failed assertion.
        /// </summary>
        /// <param name="errorText">The error text.</param>
        /// <param name="scenarioText">The scenario text.</param>
        /// <param name="bddMethodLocation">The BDD method location.</param>
        /// <param name="gameObject">The game object.</param>
        public virtual void InvokeAssertionFailed(string errorText, string scenarioText, string bddMethodLocation, GameObject gameObject)
        {
            AssertionFailed assertion = AssertionComponent.Create <AssertionFailed>(CheckMethod.Start, gameObject, "TestComponent.enabled");

            assertion.ErrorText         = errorText;
            assertion.ScenarioText      = scenarioText;
            assertion.BDDMethodLocation = bddMethodLocation;
        }
    public void Awake()
    {
        IAssertionComponentConfigurator configurator;
        FloatComparer comparer = AssertionComponent.Create <FloatComparer>(out configurator, CheckMethod.Update | CheckMethod.Start, base.gameObject, "CodeBasedAssertionExample.FloatField", 3f);

        configurator.UpdateCheckRepeatFrequency = 5;
        comparer.floatingPointError             = 0.1;
        comparer.compareTypes = FloatComparer.CompareTypes.Equal;
        AssertionComponent.Create <ValueDoesNotChange>(CheckMethod.Update | CheckMethod.Start, base.gameObject, "CodeBasedAssertionExample.FloatField");
        base.transform.position = new Vector3(0f, 3f, 0f);
        AssertionComponent.Create <FloatComparer>(CheckMethod.Update, base.gameObject, "CodeBasedAssertionExample.FloatField", base.gameObject, "transform.position.y");
        this.goReference = base.gameObject;
        AssertionComponent.Create <GeneralComparer>(CheckMethod.Update, base.gameObject, "CodeBasedAssertionExample.goReference", null).compareType = GeneralComparer.CompareType.ANotEqualsB;
    }
示例#4
0
 /// <summary>
 /// Invokes the successful assertion.
 /// </summary>
 /// <param name="gameObject">The game object.</param>
 public void InvokeAssertionSuccessful(GameObject gameObject)
 {
     AssertionComponent.Create <AssertionSuccessful>(CheckMethod.Start, gameObject, "TestComponent.enabled");
 }