public void Execute() { SelectCarType(); Brand brand = SelectBrand(); SelectColour(); IColourDecoration colourDecoration = SelectColourDeco(); EngineClass engine = SelectEngine(); SelectWheel(); IWheelDeco wheelDeco = SelectWheelDeco(); Numberplate numberplate = AssignNumberplate(); IWheel wheel = (IWheel)Activator.CreateInstance(wheelList[listOfIndex.Last()], wheelDeco); listOfIndex.RemoveAt(listOfIndex.Count - 1); ICarColour carColour = (ICarColour)Activator.CreateInstance(carColourList[listOfIndex.Last()], colourDecoration); listOfIndex.RemoveAt(listOfIndex.Count - 1); Vehicle vehicle = (Vehicle)Activator.CreateInstance(types[listOfIndex.Last()], new object[] { carColour, wheel, brand, numberplate, engine }); Console.WriteLine("Congratulation you successfully added a new vehicle"); carDealer.AddVehicleToList(vehicle); command = new PrintVehicleCommand() { List = carDealer.Vehicles }; command.Execute(); listOfIndex.Clear(); }
public void ChangePriceCommandTest() { CarDealer carDealer = new CarDealer(); Vehicle veh1 = new Car(new Black(new Matt()), new Summer(new SteelRims()), new VW(), new Numberplate("12-GG-13"), new Diesel()); Vehicle veh2 = new Car(new White(new Shiney()), new Winter(new AluRims()), new BMW(), new Numberplate("12-yy-99"), new Benzin()); Vehicle veh3 = new Car(new Green(new Metallic()), new Both(new SpareTire()), new Mercedes(), new Numberplate("24-04-09"), new Electro()); carDealer.AddVehicleToList(veh1); carDealer.AddVehicleToList(veh2); carDealer.AddVehicleToList(veh3); Assert.Equal(1, veh1.ID); Assert.Equal(2, veh2.ID); Assert.Equal(3, veh3.ID); Assert.Equal(3, carDealer.Vehicles.Count); }