public override void Display(string parentMenu) { this.MonitorExitKey(() => { while (true) { Console.Clear(); Console.WriteLine(parentMenu + " Insert Vehicle"); Console.WriteLine(); Console.WriteLine("Press [esc] any time to go back!"); Chassis chassis = CreateChassis(); var vehicleMaker = CreateVehicle(); var color = CreateColor(); var vehicle = vehicleMaker.Invoke(new VehicleMaker(), chassis, (pref) => pref.Paint(color)); Console.WriteLine(); Console.WriteLine("Press [enter] to save the vehicle"); Console.ReadKey(); var result = FleetManager.AddVehicle(vehicle).HandlerErrors((ex) => { Console.WriteLine(ex.Message); }).Result(); if (result.IsSuccess) { this.ShowSuccessMessage(); break; } this.ShowValidationErrors(result.ValidationResult); } }); }
public void When_add_vehicle_without_chassis_return_fail() { VehicleMaker volvoMaker = new VehicleMaker(); //IVehicle vehicle = volvoMaker.BuildBus(null, (preferences) => preferences.Paint("Red")); IVehicle vehicle = new CustomVehicle() { Type = Core.Domain.VehicleType.Truck, NumberOfPassagers = 1, ChassisId = null }; var result = fleetManager.AddVehicle(vehicle).HandlerErrors().Result(); Assert.True(result.IsFail, "The operation didn't fail for a invalid vehicle!"); var validationResult = result.ValidationResult.FirstOrDefault(); Assert.Contains("chassis id", validationResult.Error); }