Ejemplo n.º 1
0
 public void TestCarStart()
 {
     IVehicle raceCar = new Car(new PetrolEngine(), "Mercedes", "McLaren", "Mika Hakkinen");
     bool isFired = false;
     VehicleStartedEventArgs args = null;
     raceCar.VehicleStarted += delegate (object o, VehicleStartedEventArgs e) { isFired = true;args = e;  };
     Assert.IsFalse(isFired);
     raceCar.Start(0);
     Assert.IsFalse(isFired);
     raceCar.Engine.Fill(FuelType.Petrol);
     raceCar.Start(0);
     Assert.IsTrue(isFired);
     Assert.IsTrue(args.CarMake == "Mercedes");
     Assert.IsTrue(args.CarModel == "McLaren");
     Assert.IsTrue(args.DriverName == "Mika Hakkinen");
 }
Ejemplo n.º 2
0
 public void TestCarStop()
 {
     IVehicle raceCar = new Car(new PetrolEngine(), "Mercedes", "McLaren", "Mika Hakkinen");
     bool isFired = false;
     VehicleStoppedEventArgs args = null;
     raceCar.VehicleStopped += delegate (object o, VehicleStoppedEventArgs e) { isFired = true; args = e; };
     Assert.IsFalse(isFired);
     raceCar.Stop(1000);
     Assert.IsFalse(isFired);
     raceCar.Engine.Fill(FuelType.Petrol);
     raceCar.Start(0);
     Thread.Sleep(20000);
     raceCar.Stop(1000);
     Assert.IsTrue(isFired);
     Assert.IsTrue(Math.Round(args.AverageSpeed) == 50);
     Assert.IsTrue(args.CarMake == "Mercedes");
     Assert.IsTrue(args.CarModel == "McLaren");
 }