public IEnumerator TrailBackBorderIsCreatedAtTronBackBorder() { yield return(Given.Scene(this, "MainScene")); var tron = Find.SingleObjectById("Tron"); var originalTronBackBorder = GeometryUtils.GetBackBorder(tron); var tronTransform = tron.transform; tronTransform.GetComponent <Tron>().StartRace(); yield return(new WaitForEndOfFrame()); var trail = Find.SingleObjectById("Trail"); var trailBackBorder = GeometryUtils.GetBackBorder(trail); Assert.That(trailBackBorder, Is.EqualTo(originalTronBackBorder), "trailBackBorder"); }
public IEnumerator TrailHeightIsTronHeightAndHalfWidth() { yield return(Given.Scene(this, "MainScene")); var tron = Find.SingleObjectById("Tron"); var tronTransform = tron.transform; tronTransform.GetComponent <Tron>().StartRace(); yield return(new WaitForEndOfFrame()); var trail = Find.SingleObjectById("Trail"); var trailScale = trail.transform.localScale; var tronScale = tronTransform.localScale; Assert.That(trailScale.y, Is.EqualTo(tronScale.y), "trail height"); Assert.That(trailScale.x, Is.EqualTo(tronScale.x / 2), "trail width"); }
public IEnumerator StartsGameOnButtonClick() { yield return(Given.Scene(this, "MainScene")); yield return(new WaitForEndOfFrame()); var tron = Find.SingleObjectById("Tron"); var tronSpy = tron.AddComponent <TronSpy>(); var buttonGameObject = Find.SingleObjectById("StartButton"); var button = buttonGameObject.GetComponent <Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(tronSpy.StartRace); // Trying to get the simulation of the button click to work. No success. // It feels like Fixture is not connected to UI somehow. Experiments below... yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForSeconds(10)); // first try: button.onClick.Invoke(); - works of course button.Select(); var buttonRectTransform = button.GetComponent <RectTransform>(); // var buttonRect = buttonRectTransform.rect; // var buttonCenter = buttonRect.position; // yield return _inputSimulation.MouseLeftClick(buttonRectTransform.position); yield return(new WaitForSeconds(15)); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); Assert.That(tronSpy.StartRacingHasBeenCalled(), Is.True, "tronSpy.StartRacingHasBeenCalled() has been called"); }
public IEnumerator IsOnGridOnStartup() { yield return(Given.Scene(this, "MainScene")); const string objectId = "Tron"; var tron = Find.SingleObjectById(objectId); // Tron is based on plane Assert.That(tron.transform.position.y, Is.EqualTo(0), objectId + ".y"); // ReSharper disable CommentTypo // Tron internally is aligned that its base is the bottom // Do we write a test for that or edit in the editor? Seems like Gui fiddeling? // Assert trail is internally aligned that its base is the bottom - manual // ReSharper restore CommentTypo // Grid plane is also at 0 var grid = Find.SingleObjectById("Grid"); Assert.That(grid.transform.position.y, Is.EqualTo(0), "grid.y"); }
public IEnumerator ShouldTriggerTurnRightOnlyOnKeyPressStarted() { yield return(Given.Scene(this, "MainScene")); var tron = Find.SingleObjectById("Tron"); // TODO duplication: extract mock creation to helper method var tronTransform = tron.transform; // TODO: do we need transform? direct? var racingInteraction = tron.AddComponent <RacingInteractionSpy>(); tronTransform.GetComponent <Tron>().racingInteraction = racingInteraction; // TODO duplication: We have lots of calls like this. Maybe have Given.RaceStarted() // need also var tronTransform = tron.transform; tronTransform.GetComponent <Tron>().StartRace(); yield return(new WaitForEndOfFrame()); yield return(_inputSimulation.PressRight()); // TODO duplication: extract mock verification to helper methods Assert.That(racingInteraction.TurnRightCallCount(), Is.EqualTo(1), "TurnRight has been called"); }