public void UseCase1Tests() { // Setup string[] park = new string[100]; int actualFindPosition, actualFindPositionMc; int actualFindFreePositionMc; // Act Parking.Add(park, "bcd987", VehicleType.Car); // Park a car actualFindPosition = Parking.FindDistinct(park, "bcd987"); // Find the car Parking.Remove(park, "bcd987"); // remove the car Parking.Add(park, "afgd987", VehicleType.Car); // park car 2 Parking.Add(park, "ytrd987", VehicleType.Mc); // park Mc 1 Parking.Add(park, "aoi987", VehicleType.Car); // park car 3 Parking.Add(park, "ykad987", VehicleType.Mc); // park Mc 2 actualFindPositionMc = Parking.FindDistinct(park, "ykad987"); // find mc 2 actualFindFreePositionMc = Parking.FindFreePlace(park, VehicleType.Mc); // find free position Parking.Move(park, "ykad987", actualFindFreePositionMc); // move mc 2 to free position Parking.Remove(park, "ytrd987"); // remove mc 1 Parking.Add(park, "947tef", VehicleType.Mc); // park Mc 3 Parking.Add(park, "37hjd", VehicleType.Mc); // park Mc 4 Parking.Optimize(park); // Optimize // Verify Assert.IsTrue(actualFindPosition >= 0 && actualFindPosition < park.Length); Assert.IsTrue(actualFindPositionMc >= 0 && actualFindPositionMc < park.Length); Assert.IsTrue(actualFindFreePositionMc >= 0 && actualFindFreePositionMc < park.Length); }
public void ParkingAdd_ChangesCount() { Parking p = new Parking(); MiejsceParkingowe mp = new MiejsceParkingowe(RodzajMiejsca.Duze, false); Assert.IsTrue(p.Repo.Count == 0); p.Add(mp); Assert.IsTrue(p.Repo.Count == 1); }
static void Main(string[] args) { // Initialize the repository Parking parking = new Parking("Underground parking garage", 5); // Initialize entity Car volvo = new Car("Volvo", "XC70", 2010); // Print Car Console.WriteLine(volvo); // Volvo XC70 (2010) // Add Car parking.Add(volvo); // Remove Car Console.WriteLine(parking.Remove("Volvo", "XC90")); // False Console.WriteLine(parking.Remove("Volvo", "XC70")); // True Car peugeot = new Car("Peugeot", "307", 2011); Car audi = new Car("Audi", "S4", 2005); parking.Add(peugeot); parking.Add(audi); // Get Latest Car Car latestCar = parking.GetLatestCar(); Console.WriteLine(latestCar); // Peugeot 307 (2011) // Get Car Car audiS4 = parking.GetCar("Audi", "S4"); Console.WriteLine(audiS4); // Audi S4 (2005) // Count Console.WriteLine(parking.Count); // 2 // Get Statistics Console.WriteLine(parking.GetStatistics()); // The cars are parked in Underground parking garage: // Peugeot 307(2011) // Audi S4(2005) }
public void ParkAllFull2McMcThrowsExeptionTest() { // Should throw exception // Setup string[] park = new string[1]; park[0] = "abc123:uyt345"; //Act Parking.Add(park, "bcd987", VehicleType.Mc); // Should throw exception }
public void ParkAllFull4McMcThrowsExeptionTest() { // Should throw exception // Setup string[] park = new string[2]; park[0] = "abc123:uyt345"; park[1] = "dbc423:uto765"; //Act Parking.Add(park, "1poi43", VehicleType.Mc); // Should throw exception }
public void ParkDuplicateCarVsCarRegistrationNumberThrowsExceptionTest() { // Should throw exception // Setup string[] park = new string[2]; park[0] = null; park[1] = "uto765"; //Act Parking.Add(park, "uto765", VehicleType.Car); // Should throw exception }
public void ParkDuplicateMcVsCarRegistrationNumberThrowsExceptionTest() { // Should throw exception // Setup string[] park = new string[2]; park[0] = "abc123"; park[1] = ":dbc423"; //Act Parking.Add(park, "abc123", VehicleType.Mc); // Should throw exception }
/// <summary> /// Park Vehicle /// </summary> /// <param name="parkingPlace"></param> /// <param name="registrationNumber"></param> /// <param name="vehicleType"></param> public static void ParkVehicle(string[] parkingPlace, string registrationNumber, VehicleType vehicleType) { try { int position = Parking.Add(parkingPlace, registrationNumber, vehicleType); // Park at suitable position (if any) Messenger.WriteInformationMessage(String.Format("Your vehicle has been parked at place number {0}.", position + 1)); } catch (RegistrationNumberAlreadyExistException) { Messenger.WriteErrorMessage("Registration number already exist. Cannot have two vehicles with same."); } catch (ParkingPlaceFullException) { Messenger.WriteErrorMessage("The parking place has no room for the vehicel."); } }
public void Park1Mc1CarMcTest() { // Setup string[] park = new string[2]; park[0] = "abc123:uyt345"; park[1] = ":dbc423"; string[] expected = new string[2]; expected[0] = "abc123:uyt345"; expected[1] = "8toi43:dbc423"; int expectedPosition = 1; int actualPosition; //Act actualPosition = Parking.Add(park, "8toi43", VehicleType.Mc); MyAssert.AreEqual(expected, park); Assert.AreEqual(expectedPosition, actualPosition); }
public void Park1Mc100VehiclesTest() { // Setup string[] park = PopulateParkingPlace(100); park[0] = "abc123:uyt345"; park[1] = ":dbc423"; string[] expected = PopulateParkingPlace(100); expected[0] = "abc123:uyt345"; expected[1] = "8toi43:dbc423"; int expectedPosition = 1; int actualPosition; //Act actualPosition = Parking.Add(park, "8toi43", VehicleType.Mc); // Verify MyAssert.AreEqual(expected, park); Assert.AreEqual(expectedPosition, actualPosition); }
public void ParkGoodCustomPlateMcTest() { // Setup string[] park = new string[2]; park[0] = ":lk433"; park[1] = "dbc423:lk433"; string[] expected = new string[2]; expected[0] = GoodCustomPlateRegistrationNumber + ":lk433"; expected[1] = "dbc423:lk433"; int expectedPosition = 0; int actualPosition; //Act actualPosition = Parking.Add(park, GoodCustomPlateRegistrationNumber, VehicleType.Mc); //Verify MyAssert.AreEqual(expected, park); Assert.AreEqual(expectedPosition, actualPosition); }
public void Park1McCarNullTest() { // Setup string[] park = new string[2]; park[0] = null; park[1] = "dbc423:lk433"; string[] expected = new string[2]; expected[0] = "8toi43" + "," + DateTime.Now; expected[1] = "dbc423:lk433"; int expectedPosition = 0; int actualPosition; //Act actualPosition = Parking.Add(park, "8toi43", VehicleType.Car); //Verify MyAssert.AreEqual(expected, park); Assert.AreEqual(expectedPosition, actualPosition); }
static void MakeAndAdd(string type, string regNr, string color, string brand) { int position = -1; switch (type) { case "1": // bicycle Vehicle bike = new Bicycle(regNr, color, brand); position = Parking.Add(bike); break; case "2": // motorcycle Vehicle mc = new Motorcycle(regNr, color, brand); position = Parking.Add(mc); break; case "3": //trike Vehicle trike = new Trike(regNr, color, brand); position = Parking.Add(trike); break; case "4": //car Vehicle car = new Car(regNr, color, brand); position = Parking.Add(car); break; } if (position == -1) { Console.WriteLine("Not enough space."); } else { Console.WriteLine($"The vehicle {regNr} has been added in space {position + 1}."); } }