# I want to test the Animator component of a gameobject using nunit, but I am having issues

I made a Blender 3D model with animations. Then I used the Animator Controller, and attached it to the model. The Animator Controller has a few Boolean parameter variables like isWaving, isDoing, and isIdle and more variables like that. If, say, a non-idle action is true, then the animation of my model transitions to the next one. I am into test-driven development, but I have never done it with Unity.

I tried writing the following code to test my project:

[SetUp]
public void SetUp()
{
Crystal = GameObject.FindGameObjectWithTag("CrystalModel");
CrystalScript = Crystal.GetComponent<CrystalChanPlayer>();
CrystalAnimator = Crystal.GetComponent<Animator>(); // unity game animator
}

[Test]
public void ifSetAnimationIstodoThenToDoAnimationIsPlayed()
{
CrystalScript.setAnimationStrategy("todo"); // set strategy
CrystalScript.playAnimation(); // sets todo boolean to true and idle to false

// first debug output
Debug.LogError("todo is " + CrystalAnimator.GetBool("isDoing") +
" idle is " + CrystalAnimator.GetBool("isIdle"));

//second output
Debug.LogError("current state is " +
CrystalAnimator.GetCurrentAnimatorStateInfo(0).IsName("idle"));

Assert.True(CrystalAnimator.GetCurrentAnimatorStateInfo(0).IsName("todoAnimation"));
}


"todo is true and idle is false"
"true"

I think this is because Unity isn't really running, and my Animator doesn't get to update based on the variable changes. The first output assures me that todo is set to true and idle is false, hence the Animator should transition that animation to the todoAnimation. Yet, I can't seem to show that, in my tests.

Is there any way to test the Animator class? Are there any design patterns I can use?

I'm testing my animators by always using animator.Update(0.1f) to make them pass from states to states.
CrystalScript.setAnimationStrategy("todo"); // set strategy