public Oprations(int capacity) { garageHandler = new GarageHandler(capacity); garageHandler.Add(new Car("car123", "Red", 4, 12)); counter = garageHandler.garage.Counter(); Capacity = capacity; }
public void RemoveVehicle_WithExistingRegNo_ShouldBeRemoved() { string ExpectedRegNr = "DC34b"; int ExpectedNrOfWheels = 3; string ExpectedColor = "White"; double ExpectedWingSpan = 10.5; IVehicle airplane = new Airplane(ExpectedRegNr, ExpectedNrOfWheels, ExpectedColor, ExpectedWingSpan); GarageHandler garageHandler = new GarageHandler(1); garageHandler.Add(airplane); string ExpectedString = ""; Assert.IsTrue(garageHandler.garage.Remove(ExpectedRegNr)); var actual = garageHandler.PrintAll(); Assert.AreEqual(ExpectedString, actual); }
public void ReadFromFile() { WriteAndReadFile wdf = new WriteAndReadFile(Capacity); var lines = wdf.ReadFile(); var vehList = garageHandler.garage.ToList(); if (vehList.Capacity < lines.Capacity) { "You will not be able to restore all the data because the new capacity less than the data size!\n\n".PrintLine(); } foreach (var line in lines) { string[] entries = line.Split(','); { if (entries[0].ToLower() == "car") { Car car = new Car(entries[1], entries[2], int.Parse(entries[3]), int.Parse(entries[4])); if (!RegistrationIsUnique(car)) { garageHandler.Add(car); } } if (entries[0].ToLower() == "boat") { Boat boat = new Boat(entries[1], entries[2], int.Parse(entries[3]), double.Parse(entries[4])); garageHandler.Add(boat); } if (entries[0].ToLower() == "airplane") { Airplane air = new Airplane(entries[1], entries[2], int.Parse(entries[3]), int.Parse(entries[4])); if (!RegistrationIsUnique(air)) { garageHandler.Add(air); } } if (entries[0].ToLower() == "bus") { Bus bus = new Bus(entries[1], entries[2], int.Parse(entries[3]), int.Parse(entries[4])); if (!RegistrationIsUnique(bus)) { garageHandler.Add(bus); } } if (entries[0].ToLower() == "motorcycle") { Motorcycle motor = new Motorcycle(entries[1], entries[2], int.Parse(entries[3]), entries[4]); if (!RegistrationIsUnique(motor)) { garageHandler.Add(motor); } } } } { "Restoring the Date done successfully\n\n".PrintLine(); } }