public void it_should_pass_inspection_for_weekly_product() { var inspectionId = InspectionId.Create("inspection-identifier"); LicencePlate licencePlate = LicencePlate.Create("123-456"); const string location = "Kernow"; var inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero); var stream = new object[] { new VehicleRegistered(licencePlate.ToString()), // In the past new VehicleBooked( licencePlate: licencePlate.ToString(), location: location, start: inspectionTime.AddDays(-57).ToUnixTimeSeconds(), finish: inspectionTime.AddDays(-50).ToUnixTimeSeconds()), // Covers current inspection new VehicleBooked( licencePlate: licencePlate.ToString(), location: location, start: inspectionTime.AddDays(-2).ToUnixTimeSeconds(), finish: inspectionTime.AddDays(5).ToUnixTimeSeconds()), // In the future new VehicleBooked( licencePlate: licencePlate.ToString(), location: location, start: inspectionTime.AddDays(1).ToUnixTimeSeconds(), finish: inspectionTime.AddDays(8).ToUnixTimeSeconds()) }; var vehicle = Vehicle.FromStream(licencePlate, stream); vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location); DeepAssert.Equal(Array.Empty <object>(), vehicle.TakeChanges().ToArray()); }
//DISPLAYING ON UI THREAD #region displayng on UI thread public void DisplayPlate(LicencePlate plate) { MethodInvoker invoker = delegate { DisplayVehicleCount(plate); //lvResults.Items.Add(new ListViewItem(plate.toArray())); lvResults.Items.Insert(0, new ListViewItem(plate.toArray())); lvResults.Items[0].BackColor = plate.plateNumber.Contains("error") ? Color.Red : Color.LawnGreen; }; BeginInvoke(invoker); }
public void It_should_book_unregistered_vehicle() { var vehicle = Vehicle.FromStream(LicencePlate.Create("123-123")); vehicle.Book(LicencePlate.Create("123-123"), "Kernow", 1579132800, EndOf.Day); var expected = new object[] { new VehicleRegistered(licencePlate: "123-123"), new VehicleBooked( licencePlate: "123-123", location: "Kernow", start: new DateTimeOffset(new DateTime(2020, 01, 16)).ToUnixTimeSeconds(), finish: new DateTimeOffset(new DateTime(2020, 01, 17)).AddSeconds(-1).ToUnixTimeSeconds() ) }; DeepAssert.Equal(expected, vehicle.TakeChanges().ToArray()); Assert.Equal(1, vehicle.Version); }
public void DisplayVehicleCount(LicencePlate plate) { MethodInvoker invoker = delegate { statsDataGrid.Rows[0].Cells[1].Value = _vehicleCount; if (plate.isRegistered) { int count = Convert.ToInt32(statsDataGrid.Rows[1].Cells[1].Value.ToString()); statsDataGrid.Rows[1].Cells[1].Value = ++count; } else { int count = Convert.ToInt32(statsDataGrid.Rows[2].Cells[1].Value.ToString()); statsDataGrid.Rows[2].Cells[1].Value = ++count; } }; BeginInvoke(invoker); }
public void it_should_fail_inspection() { var inspectionId = InspectionId.Create("inspection-identifier"); LicencePlate licencePlate = LicencePlate.Create("123-456"); const string location = "Kernow"; var inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero); var vehicle = Vehicle.FromStream(licencePlate); vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location); var expected = new object[] { new VehicleRegistered(licencePlate: licencePlate.ToString()), new VehicleUnbooked( inspectionId: inspectionId.ToString(), licencePlate: licencePlate.ToString(), location: location) }; DeepAssert.Equal(expected, vehicle.TakeChanges().ToArray()); }
public void it_should_pass_inspection_for_all_day_product() { var inspectionId = InspectionId.Create("inspection-identifier"); LicencePlate licencePlate = LicencePlate.Create("123-456"); const string location = "Kernow"; var inspectionTime = new DateTimeOffset(2020, 2, 15, 10, 00, 00, 00, TimeSpan.Zero); var stream = new object[] { new VehicleRegistered(licencePlate.ToString()), // start at half-eight pm, ends one second before midnight. new VehicleBooked( licencePlate: licencePlate.ToString(), location: location, start: 1581755400, // 02/15/2020 @ 8:30am (UTC) finish: 1581811199) // 02/15/2020 @ 11:59pm (UTC) }; var vehicle = Vehicle.FromStream(licencePlate, stream); vehicle.Inspect(inspectionId, inspectionTime, licencePlate, location); DeepAssert.Equal(Array.Empty <object>(), vehicle.TakeChanges().ToArray()); }
/// <summary> /// https://lonewolfonline.net/list-net-culture-country-codes/ /// Valid form 'CZ*AZ8360' /// </summary> /// <param name="inputString"></param> /// <param name="licencePlate"></param> /// <returns></returns> public static bool TrySanitizeInputToLicencePlate(string inputString, out LicencePlate licencePlate) { licencePlate = null; if (string.IsNullOrWhiteSpace(inputString)) { return(false); } var str = inputString.Replace(" ", ""); var semicollonPos = str.IndexOf('*'); if (semicollonPos < 0) { return(false); } var country = str.Substring(0, semicollonPos).ToUpperInvariant(); var number = str.Substring(semicollonPos + 1).ToUpperInvariant(); licencePlate = new LicencePlate(country, number); return(true); }
public VehicleModel() { VehicleOverview = new VehicleOverview(); engine = new Engine(); starter = new Starter(); gearBox = new GearBox(); vehGearNum = 0; for (int i = 0; i < subGears.Length; i++) { subGears[i] = new SubGear(); } windForce = new WindForce(); steeringFactor = new SteeringFactor(); steering = new Steering(); fuelTank = new FuelTank(); for (int i = 0; i < otherSteerings.Length; i++) { otherSteerings[i] = new OtherSteering(); } carVibration = new CarVibration(); brakesCommon = new Brakes(); physicsCrashSetting = new PhysicsCrashSetting(); ignoreHeadCollision = false; exhaust = new Exhaust(); roughness = new Roughness(); engineHealth = new EngineHealth(); fuelTankOnCrash = 0; engineParticles = new EngineParticles(); gearboxSettings = new GearboxSettings(); wheels = new Wheel(); body = new Body(); bumper = new Bumper(); windowGlass = new WindowGlass(); light = new Light(); licencePlate = new LicencePlate(); mirror = new Mirror(); wing = new Wing(); door = new Door(); roof = new Roof(); unknown = new Unknown(); engineSoundSet = new EngineSoundSet(); engineSound1 = new EngineSound(); engineSound2 = new EngineSound(); engineSound3 = new EngineSound(); engineSound4 = new EngineSound4(); insideSoundSet = new InsideSoundSet(); carSmallHitType = new CarSmallHitType(); carShortCrashTypeB1 = new CarShortCrashType(); carShortCrashWithGlassTypeC1 = new CarShortCrashType(); unknownSound1 = ""; unknownSound2 = ""; engineStartSound = new EngineStartSound(); engineSoundDriving = new EngineSoundDriving(); for (int i = 0; i < engineSoundOnGears.Length; i++) { engineSoundOnGears[i] = new EngineSoundOnGear(); } engineSoundIdle = new EngineSoundIdle(); wheelSoundWhilePunctured = new WheelSoundWhilePunctured(); carSmallHitType1 = new CarSmallHitType(); carLongCrashType1 = new CarLongCrashType(); carShortCrashWithGlassType1 = new CarShortCrashType(); doorOpenCloseSound = new DoorOpenCloseSound(); insideSoundSet = new InsideSoundSet(); carSmallHitType = new CarSmallHitType(); carLongCrashType2 = new CarLongCrashType(); carShortCrashTypeB1 = new CarShortCrashType(); carShortCrashWithGlassTypeC1 = new CarShortCrashType(); unknownSound1 = ""; unknownSound2 = ""; carShortCrashTypeB2 = new CarShortCrashType(); carShortCrashWithGlassType1 = new CarShortCrashType(); doorOpenCloseSound = new DoorOpenCloseSound(); }