Example #1
0
        public void TestRecieveEmissionsAndChangeSpeed()
        {
            //create class
            var vehicle = new VehicleSimulator.Vehicle(30, new List <VehicleSimulator.WayPoint>()
            {
                new WayPoint(33.833769, -117), new WayPoint(33.82652, -117), new WayPoint(33.833769, -117)
            });

            //attach listener
            var listen = new Listener(vehicle);


            var factory = new System.Threading.Tasks.TaskFactory();

            //start the vehicle
            var task = factory.StartNew(() => vehicle.Drive());

            //wait 10 seconds
            System.Threading.Thread.Sleep(30000);


            vehicle.ChangeSpeed(60);

            //wait for the vehicle to finish
            task.Wait();

            Console.WriteLine(listen.CoordinateLog.Split(" ".ToCharArray()).Where(s => s == "Got").Count());


            //parse the listener's log to get the number of coordinate events that happened
            Assert.IsTrue(listen.CoordinateLog.Split(" ".ToCharArray()).Where(str => str == "Got").Count() == 22);
        }
Example #2
0
        public void CanUpdateVehicleSpeed()
        {
            var simulator = new VehicleSimulator.Vehicle(25, new List <VehicleSimulator.WayPoint>());

            simulator.ChangeSpeed(30);

            Assert.AreEqual(30, simulator.CurrentSpeed);
        }
Example #3
0
        public void TestRecieveEmissions()
        {
            //create class
            var vehicle = new VehicleSimulator.Vehicle(25, new List <VehicleSimulator.WayPoint>()
            {
                new WayPoint(33.833769, -117), new WayPoint(33.82652, -117), new WayPoint(33.833769, -117)
            });

            //attach listener
            var listen = new Listener(vehicle);

            //start the vehicle
            vehicle.Drive();

            //parse the listener's log to get the number of coordinate events that happened
            Assert.IsTrue(listen.CoordinateLog.Split(" ".ToCharArray()).Where(s => s == "Got").Count() == 18);
        }
Example #4
0
 /// <summary>
 /// Takes in a vehicle and listens to the events
 /// </summary>
 /// <param name="vehicle">The simulated vehicle</param>
 public Listener(VehicleSimulator.Vehicle vehicle)
 {
     CoordinateLog          = string.Empty;
     _vehicle               = vehicle;
     vehicle.NewCoordinate += new EventHandler <ICoordinate>(GotNewCoordinate);
 }