public IEnumerator MovementConsumesFuel() { GameObject digger = IntegrationTestScript.TestDigger(); DiggerControl control = digger.GetComponent <DiggerControl>(); FuelBehaviour fb = digger.GetComponent <FuelBehaviour>(); fb.fuel = 2; yield return(null); var initialFuel = fb.fuel; // To do this, move down twice and ensure that fuel has been consumed. control.TestMovement("down", digger); Assert.AreEqual(fb.fuel, initialFuel - 1); // Use the Assert class to test conditions. // yield to skip a frame }
public IEnumerator CannotDigUp() { GameObject digger = IntegrationTestScript.TestDigger(); DiggerControl control = digger.GetComponent <DiggerControl>(); yield return(null); Vector3 initialPos = digger.transform.position; control.TestMovement("down", digger); control.TestMovement("down", digger); control.TestMovement("down", digger); Assert.Less(digger.transform.position.y, initialPos.y); initialPos.y = digger.transform.position.y; Assert.AreEqual(digger.transform.position.x, initialPos.x); control.TestMovement("right", digger); Assert.AreEqual(digger.transform.position.y, initialPos.y); Assert.Greater(digger.transform.position.x, initialPos.x); control.TestMovement("up", digger); Assert.Greater(digger.transform.position.y, initialPos.y); }