private void checkLight(float time) { if (stopLight != null) { Stoplight stopScript = (Stoplight)stopLight.GetComponent("Stoplight"); if (stopScript.stop) { if (ProximityTester.proximityTest(stoplightProximityRange, this.transform.position, stopLight.transform.position)) { //car stops in place until light is go if (!hasLogged) { Debug.Log("stop"); } hasLogged = true; } else { checkCarCollision(time); } } else { checkCarCollision(time); } } else { checkCarCollision(time); } }
public void ShouldTransitionGreenToYellow() { Stoplight light = new Stoplight(); light.Next(); Assert.AreEqual(Stoplight.Yellow, light.CurrentColor); }
public void ShouldTransitionYellowToRed() { Stoplight light = new Stoplight(); light.Next(); light.Next(); Assert.AreEqual(Stoplight.Red, light.CurrentColor); }
public void ShouldTransitionRedToGreen() { Stoplight light = new Stoplight(); light.Next(); light.Next(); light.Next(); Assert.AreEqual(Stoplight.Green, light.CurrentColor); }
public void ShouldLogMessageOnChange() { Stoplight light = new Stoplight(); MockLogger logger = new MockLogger(); light.Logger = logger; light.Next(); Assert.IsNotNull(logger.LastMessage); Assert.IsTrue(logger.LastMessage.StartsWith("LIGHT CHANGED TO")); }
void ICommandRunner.Run(string[] args, Stoplight stoplight) { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); _stoplight = stoplight ?? new Stoplight(); //TODO: figure out how to load the service config before the service is running. // CanStop and CanPauseAndContinue can only be set before the service starts // but we can't get the current service until there's a process id. ARG!!!! CanStop = true; Run(this); Log.Debug("Run(this) completed"); }
public void ShouldRaiseChangedEventOnTransition() { bool eventFired = false; StoplightColors newColor = StoplightColors.Green; Stoplight light = new Stoplight(); light.Changed += delegate(object sender, LightChangedEventArgs e) { eventFired = true; newColor = e.CurrentColor; }; light.Next(); Assert.IsTrue(eventFired); Assert.AreEqual(Stoplight.Yellow, newColor); }
public void SetView(IStoplightView view) { this.view = view; view.PropertyChanged += OnViewPropertyChanged; view.UpdateClicked += OnViewUpdateClicked; view.ForceChangeClicked += OnViewForceChangeClicked; Schedule.ChangeLight += delegate { Stoplight.Next(); }; Stoplight.Changed += OnStoplightChanged; view.GreenDuration = "3000"; view.YellowDuration = "500"; view.RedDuration = "5000"; view.CurrentColor = Color.Green; Schedule.Update(TimeSpan.FromMilliseconds(3000), TimeSpan.FromMilliseconds(500), TimeSpan.FromMilliseconds(5000)); Schedule.Start(); }
public void OnScheduledLightChange(object sender, EventArgs e) { Stoplight.Next(); }
//search through the queue to see if the light we want to put in the queue is already in the queue private bool SearchQueueForOneOrThree(Stoplight stoplight) { foreach (Stoplight oStoplight in qNextLightUp) { if (oStoplight == stoplight) return true; } return false; }
//puts light next on the queue if it isn't already in the queue private void EnqueueLight(Stoplight stoplight) { bool IsFoundInQueue; //if the queue is not empty if (qNextLightUp.Count != 0) { if (stoplight == LightTwo || stoplight == LightFour) //search through the queue to see if lights two or four are already in the queue IsFoundInQueue = SearchQueueForTwoOrFour(); else //search through the queue to see if the light we want to put in the queue is already in the queue IsFoundInQueue = SearchQueueForOneOrThree(stoplight); //if the light is not already in the queue, put the light in the queue if (IsFoundInQueue == false) qNextLightUp.Enqueue(stoplight); } else //if the queue is empty qNextLightUp.Enqueue(stoplight); }
public void ShouldInitializeToGreen() { Stoplight light = new Stoplight(); Assert.AreEqual(Stoplight.Green, light.CurrentColor); }