/// <summary> /// Initialises a new instance of the <see cref="DriverModel"/> class and specifies the /// driver's Id. /// </summary> /// <param name="id">The driver's Id.</param> public DriverModel(int id) { Id = id; LapTimes = new LapTimesModel(); PitTimes = new PostedTimeCollectionModel(); QuallyTimes = new QuallyTimesModel(); Status = DriverStatus.InPits; Builder = new DriverModelBuilder(this); }
public void BuildReturnsChromeDirver() { // Arrange var driverModelBuilder = new DriverModelBuilder(); // Act _webDriver = driverModelBuilder.Build(); // Assert Assert.IsInstanceOf <ChromeDriver>(_webDriver); }
public static CarModel Create(Car car) { var carBuilder = new CarModelBuilder(new VINParserBase()); var driverBuilder = new DriverModelBuilder() .WithName(car.Driver.Person.Name) .WithMiddleName(car.Driver.Person.MiddleName) .WithLastName(car.Driver.Person.LastName) .WithImage(car.Driver.Person.Photo.BytiesToImage()) .WithDescription(car.Driver.Person.Description) .WithEmail(car.Driver.Person.Email) .WithPhone(car.Driver.Person.Phone) .Works .At(car.Driver.CompanyId, car.Driver.Company.Name) .AsA(car.Driver.JobId, car.Driver.Job.Name) .Lives .At(car.Driver.Person.Address.StreetId, car.Driver.Person.Address.Street.Street1) .WithHouseNumber(car.Driver.Person.Address.Number) .WithPostcode(car.Driver.Person.Address.Postcode) .Passport .WithSerial(car.Driver.Person.Passport.Serial) .WithNumber(car.Driver.Person.Passport.Number) .WithId(car.DriverId); var completedCar = carBuilder .WithId(car.Id) .WithVIN(car.VIN) .WithWeight(car.Weight) .WithYear(car.Year) .Model .WithId(car.ModelId) .Called(car.Model.Name) .WithManufacturer(car.Model.ManufaturerId, car.Model.Manufaturer.Name) .WithEngine(car.Model.EngineTypeId, car.Model.EngineType.Type) .DriverType .WithId(car.TypeOfDriveId) .WithType(car.TypeOfDrive.Value) .Color .WithId(car.ColorId) .WithColorCode(car.Color.Code) .WithValue(car.Color.Value.ToString()) .IsMetallic(car.Color.IsMettalic) .WithDriver(driverBuilder) .Build(); return(completedCar); }
private void AddButton_Click(object sender, EventArgs e) { try { var carBuilder = new CarModelBuilder(new VINParserBase()); var driverBulder = new DriverModelBuilder(); var driver = EntityContextSingleton.FindDriverOrDefault(NameBox.Text, MiddleNameBox.Text, LastNameBox.Text); if (driver != null) { driverBulder.WithId(driver.Id); } else { new DriverCreatingForm().ShowDialog(); driver = EntityContextSingleton.FindDriverOrDefault(NameBox.Text, MiddleNameBox.Text, LastNameBox.Text); driverBulder.WithId(driver.Id); } var completedCar = carBuilder .Color .WithColorCode(ColorBox.Text) .Model .WithManufacturer(0, ManufacturerBox.Text) .WithEngine(0, TypeOfEngine.Text) .Called(ModelBox.Text) .DriverType .WithType(DriveTypeBox.Text) .WithVIN(VINBox.Text) .WithYear(CarYearBox.Value.Year) .WithWeight(int.Parse(WeightBox.Text)) .WithDriver(driverBulder) .Build(); _controller.Insert(completedCar); } catch (Exception ex) { _controller.DialogService.ShowErrorMessage("Yay", ex.Message); } finally { _controller.DialogService.ShowMessage("Yay", "Yay"); } }
private void DoneButton_Click(object sender, EventArgs e) { try { Models.DriverModel driver = null; DriverModelBuilder driverBuilder = new DriverModelBuilder(); if (DriverPhotoBox.Image == null) { throw new Exception("Please upload driver photo !!!"); } driver = driverBuilder .WithId(0) .WithName(NameBox.Text) .WithMiddleName(MIddleNameBox.Text) .WithLastName(LastNameBox.Text) .WithDescription(DesriptionBox.Text) .WithEmail(EmailBox.Text) .WithPhone(PhoneBox.Text) .WithImage(DriverPhotoBox.Image) .Lives .At(0, StreetBox.Text) .WithHouseNumber(HouseNumberBox.Text) .WithPostcode(PostcodeBox.Text) .Works .At(0, CompanyBox.Text) .AsA(0, JobBox.Text) .Passport .WithSerial(int.Parse(PassportSerialBox.Text)) .WithNumber(int.Parse(PassportNumberBox.Text)) .Build(); _controller.Insert(driver); } catch (Exception ex) { _controller.DialogService.ShowErrorMessage("ERROR", ex.Message); } }
public CarModelBuilder WithDriver(DriverModelBuilder builder) { _root.Driver = builder.Build(); return(this); }