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); }
public void When_add_a_new_valid_vehicle_return_success() { IVehicle vehicle = new CustomVehicle() { Type = Core.Domain.VehicleType.Truck, NumberOfPassagers = 1, Color = "BLUE", ChassisId = new Core.Domain.Chassis() { ChassisNumber = 100, ChassisSeries = Guid.NewGuid().ToString() } }; var result = fleetManager.AddVehicle(vehicle).HandlerErrors().Result(); Assert.True(result.IsSuccess, "The operation failed for a valid vehicle!"); Assert.True(result.ValidationResult.All(a => a.IsValid), "There are fail validation results for a valid vehicle!"); }
public void When_delete_a_vehicle_not_stored_return_fail() { IVehicle vehicle = new CustomVehicle() { Type = Core.Domain.VehicleType.Truck, NumberOfPassagers = 1, Color = "BLUE", ChassisId = new Core.Domain.Chassis() { ChassisNumber = 9999, ChassisSeries = Guid.NewGuid().ToString() } }; var result = fleetManager.DeleteVehicle(vehicle, () => true).HandlerErrors().Result(); Assert.True(result.IsFail, "The operation not failed for an invalid vehicle!"); Assert.True(result.ValidationResult.Any(a => !a.IsValid), "There aren't fail validation results for an invalid vehicle!"); }
public async Task <string> AddCustomVehicle([FromBody] CustomVehicle customVehicle) { if (ModelState.IsValid) { var headers = new Dictionary <string, string>(); var tokenGenerated = HttpContext.Session.GetHmacToken(); headers.Add("X-Hmac", tokenGenerated); headers.Add("X-PublicKey", HttpContext.Session.GetUserPublicKey()); string queryStr = _queryCreater.GetQueryStringFromObject(customVehicle); var response = await HttpClientRequestFactory.Get("http://proxy.mansis.co.za:18443/SlimProxyBoot.php?" + queryStr, headers); var data = response.Content.ReadAsStringAsync().Result; return(data.ToString()); } else { throw new Exception("Model state is not valid"); } }
public void onCreate(string regNum, DateTime parkedDateTime, string type = "", int size = 0) { Singelton singleton = Singelton.Instance; if (type.ToLower().Equals("car")) { Vehicle car = new Car(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = car; } else if (type.ToLower().Equals("mc")) { Vehicle mc = new MC(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = mc; } else if (!type.ToLower().Equals("mc") && !type.ToLower().Equals("car")) { Vehicle custom = new CustomVehicle(regNum, type, size, parkedDateTime); singleton.Return_Vehicle = custom; } }
public void getCost(DateTime parkedDateTime, string type) { if (type.ToLower().Equals("car")) { Singelton singleton = Singelton.Instance; iPriceCalculator iCar = new Car(parkedDateTime); singleton.Return_Cost = iCar; } else if (type.ToLower().Equals("mc")) { Singelton singleton = Singelton.Instance; iPriceCalculator iMC = new MC(parkedDateTime); singleton.Return_Cost = iMC; } else { Singelton singleton = Singelton.Instance; iPriceCalculator iCustom = new CustomVehicle(parkedDateTime); singleton.Return_Cost = iCustom; } }
/// <summary> /// Gets current vehicle data /// </summary> /// <returns></returns> private static unsafe CustomVehicle GetCurrentVehicleData() { int vehicle = Game.Player.Character.CurrentVehicle.Handle; CustomVehicle cv = new CustomVehicle(); cv.Model = Function.Call<int>(Hash.GET_ENTITY_MODEL, vehicle); int primaryColor = 0, secondaryColor = 0; Function.Call(Hash.GET_VEHICLE_COLOURS, vehicle, &primaryColor, &secondaryColor); cv.PrimaryColor = primaryColor; cv.SecondaryColor = secondaryColor; int pearlColor = 0, wheelColor = 0; Function.Call(Hash.GET_VEHICLE_EXTRA_COLOURS, vehicle, &pearlColor, &wheelColor); cv.PearlTopcoatColor = pearlColor; cv.WheelColor = wheelColor; int mod1a = 0, mod1b = 0, mod1c = 0; Function.Call(Hash.GET_VEHICLE_MOD_COLOR_1, vehicle, &mod1a, &mod1b, &mod1c); cv.ModColor1[0] = mod1a; cv.ModColor1[1] = mod1b; cv.ModColor1[2] = mod1c; int mod2a = 0, mod2b = 0; Function.Call(Hash.GET_VEHICLE_MOD_COLOR_2, vehicle, &mod2a, &mod2b); cv.ModColor2[0] = mod2a; cv.ModColor2[1] = mod2b; int cp1r = 0, cp1g = 0, cp1b = 0; Function.Call(Hash.GET_VEHICLE_CUSTOM_PRIMARY_COLOUR, vehicle, &cp1r, &cp1g, &cp1b); cv.CustomPrimaryColor = Color.FromArgb(cp1r, cp1g, cp1b); int cp2r = 0, cp2g = 0, cp2b = 0; Function.Call(Hash.GET_VEHICLE_CUSTOM_SECONDARY_COLOUR, vehicle, &cp2r, &cp2g, &cp2b); cv.CustomSecondaryColor = Color.FromArgb(cp2r, cp2g, cp2b); cv.Livery = Function.Call<int>(Hash.GET_VEHICLE_LIVERY, vehicle); cv.LicensePlateText = Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, vehicle); cv.LicensePlateIndex = Function.Call<int>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX, vehicle); cv.WheelType = Function.Call<int>(Hash.GET_VEHICLE_WHEEL_TYPE, vehicle); cv.WindowTint = Function.Call<int>(Hash.GET_VEHICLE_WINDOW_TINT, vehicle); cv.BulletproofTyre = !Function.Call<bool>(Hash.GET_VEHICLE_TYRES_CAN_BURST, vehicle); cv.CustomTyre = Function.Call<bool>(Hash.GET_VEHICLE_MOD_VARIATION, vehicle, Vehicle.Mod.MOD_INDEX_CUSTOM_TYRES); for (int i = 0; i < CustomVehicle.EXTRA_COUNT; i++) { if (!Function.Call<bool>(Hash.DOES_EXTRA_EXIST, vehicle, i)) { cv.ExtraEnbled[i] = null; } else { cv.ExtraEnbled[i] = Function.Call<bool>(Hash.IS_VEHICLE_EXTRA_TURNED_ON, vehicle, i); } } int toggleIndex = 0; int modIndex = 0; for (int i = 0; i < CustomVehicle.MOD_COUNT; i++) { if (i >= CustomVehicle.TOGGLE_BEGIN && i <= CustomVehicle.TOGGLE_END) { cv.Toggles[toggleIndex++] = Function.Call<bool>(Hash.IS_TOGGLE_MOD_ON, vehicle, i); } else { cv.Mods[modIndex++] = Function.Call<int>(Hash.GET_VEHICLE_MOD, vehicle, i); } } return cv; }
static void Main(string[] args) { Console.InputEncoding = Encoding.Unicode; Console.OutputEncoding = Encoding.Unicode; Singelton S = Singelton.Instance; Parkering.Parkering parkering = new Parkering.Parkering(); Car car1 = new Car("car1"); Car car2 = new Car("car2"); Car car3 = new Car("жэф"); MC mc1 = new MC("mc1"); MC mc2 = new MC("mc2"); MC mc3 = new MC("mc3"); CustomVehicle cv1 = new CustomVehicle("cv1", "cykel", 10); CustomVehicle cv2 = new CustomVehicle("cv2", "cykel", 10); CustomVehicle cv3 = new CustomVehicle("cv3", "cykel", 10); CustomVehicle cv4 = new CustomVehicle("cv4", "scooter", 35); CustomVehicle cv5 = new CustomVehicle("фый", "skateboard", 5); parkering.Park(car1, 0); parkering.Park(car2, 98); parkering.Park(car3, 99); parkering.Park(mc1, 5); parkering.Park(mc2, 15); parkering.Park(mc3, 16); parkering.Park(cv1, 17); parkering.Park(cv2, 18); parkering.Park(cv3, 19); parkering.Park(cv4, 20); parkering.Park(cv5, 21); while (true) { int x = Menu.MenuPrint(); if (x >= 0) { switch (x) { case 1: if (Menu.MenuPark()) { int userChoise = Menu.ParkAt(); if (userChoise == 1) { parkering.Park(S.Return_Vehicle); } if (userChoise == 2) { int spot = Menu.ChooseASpot(); parkering.Park(S.Return_Vehicle, spot); } } break; case 2: if (Menu.MenuRemove(out string regNum)) { parkering.Remove(regNum); } break; case 3: if (Menu.MenuMove(out regNum, out int index)) { string moved = parkering.Move(regNum, index, out string errorMove); if (errorMove.Equals("")) { Menu.PrintGreen(moved); } else { Menu.PrintError(errorMove); } } break; case 4: if (Menu.RegNumCheck(out string userInput, out string error)) { int found = parkering.Search(userInput); Menu.PrintGreen($"{userInput} was found at {found}"); } else { Menu.PrintError(error); } break; case 5: if (Menu.MenuIndex(out int output)) { if (output >= 0 && output < 100) { Menu.PrintGreen(parkering[output].ToString()); } else { Menu.PrintError($"Spot {output}, doesnt exsist"); } } break; case 6: if (parkering.Overview().Length > 0) { parkering.PrintOverview(); } parkering.Overview(); break; case 7: parkering.Read(); break; case 8: parkering.Write(); break; case 9: parkering.SortMC(); break; case 10: parkering.Sort(); break; default: Console.WriteLine("Default case"); break; } } else { Menu.PrintError("Provide a digit between 1-10"); } } }