Пример #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);
        }
Пример #2
0
        public void CanUpdateVehicleSpeed()
        {
            var simulator = new VehicleSimulator.Vehicle(25, new List <VehicleSimulator.WayPoint>());

            simulator.ChangeSpeed(30);

            Assert.AreEqual(30, simulator.CurrentSpeed);
        }