public IEnumerator StartsRacingOnButtonClick() { Time.timeScale = 10.0f; yield return(Given.Scene(this, "MainScene")); var tron = Find.SingleObjectById("Tron"); var tronTransform = tron.transform; var originalPosition = tronTransform.position; // was tronTransform.GetComponent<Tron>().StartRace(); ClickStartButton(); const float someDistance = 0.5f; var tronMoved = new ObjectMovedPredicate(tronTransform, someDistance); var waiter = new WaitUntilOrTimeout(tronMoved.HasMoved, 2.0f); yield return(waiter); waiter.AssertTimeoutWasNotReached("move of Tron"); // ReSharper disable once Unity.InefficientPropertyAccess var newPosition = tronTransform.position; Assert.That(newPosition.y, Is.EqualTo(originalPosition.y)); Assert.That(tronMoved.CurrentDistance, Is.GreaterThan(someDistance)); }
public IEnumerator TrailGetsLongerDuringRace() { yield return(Given.Scene(this, "MainScene")); var tron = Find.SingleObjectById("Tron"); var originalTronBackBorder = GeometryUtils.GetBackBorder(tron); var tronTransform = tron.transform; tronTransform.GetComponent <Tron>().StartRace(); var tronMoved = new ObjectMovedPredicate(tronTransform, 0.5f); var waiter = new WaitUntilOrTimeout(tronMoved.HasMoved, 2.0f); yield return(waiter); waiter.AssertTimeoutWasNotReached("move of Tron"); var currentTronBackBorder = GeometryUtils.GetBackBorder(tron); var trail = Find.SingleObjectById("Trail"); // still at same back position var trailBackBorder = GeometryUtils.GetBackBorder(trail); var comparer = new Vector3EqualityComparer(0.0001f); Assert.That(trailBackBorder, Is.EqualTo(originalTronBackBorder).Using(comparer), "trailBackBorder"); var trailFrontBorder = GeometryUtils.GetFrontBorder(trail); Assert.That(trailFrontBorder, Is.EqualTo(currentTronBackBorder).Using(comparer), "trailFrontBorder"); }