Exemplo n.º 1
0
 public void Test_InsertMotorbike_IncorrectPlace_ShouldReturnErrorMessage()
 {
     var park = new VehiclePark(2, 2);
     var motorbike = new Motorbike("CA1011AH", "John Smith", 1);
     var message = park.InsertMotorbike(motorbike, 1, 10, new DateTime(2015, 5, 10, 10, 30, 0));
     Assert.AreEqual("There is no place 10 in sector 1", message);
 }
Exemplo n.º 2
0
 public void Test_InsertMotorbike_CorrectParameters_ShouldInsertTheMotorbike()
 {
     var park = new VehiclePark(2, 2);
     var motorbike = new Motorbike("CA1011AH", "John Smith", 1);
     var message = park.InsertMotorbike(motorbike, 1, 1, new DateTime(2015, 5, 10, 10, 30, 0));
     Assert.AreEqual("Motorbike parked successfully at place (1,1)", message);
 }
Exemplo n.º 3
0
        public void Test_InsertMotorbike_WithSameLicensePlate_ShouldReturnErrorMessage()
        {
            var park = new VehiclePark(2, 2);
            var motorbike = new Motorbike("CA1011AH", "John Smith", 1);
            park.InsertMotorbike(motorbike, 1, 1, new DateTime(2015, 5, 10, 10, 30, 0));

            var otherMotorbike = new Motorbike("CA1011AH", "Jane Smith", 1);
            var message = park.InsertMotorbike(otherMotorbike, 1, 2, new DateTime(2015, 5, 10, 12, 30, 0));
            Assert.AreEqual("There is already a vehicle with license plate CA1011AH in the park", message);
        }
Exemplo n.º 4
0
        public void Test_InsertMotorbike_OccupiedPlace_ShouldReturnErrorMessage()
        {
            var park = new VehiclePark(2, 2);
            var motorbike = new Motorbike("CA1011AH", "John Smith", 1);
            park.InsertMotorbike(motorbike, 1, 1, new DateTime(2015, 5, 10, 10, 30, 0));

            var otherMotorbike = new Motorbike("CA1022AH", "Jane Smith", 1);
            var message = park.InsertMotorbike(otherMotorbike, 1, 1, new DateTime(2015, 5, 10, 12, 30, 0));
            Assert.AreEqual("The place (1,1) is occupied", message);
        }
Exemplo n.º 5
0
 private string ExecuteParkMotorbikeCommand(ICommand command)
 {
     var motorbike = new Motorbike(command.Parameters["licensePlate"], command.Parameters["owner"], int.Parse(command.Parameters["hours"]));
     string commandResult = this.VehiclePark.InsertMotorbike(
         motorbike,
         int.Parse(command.Parameters["sector"]),
         int.Parse(command.Parameters["place"]),
         DateTimeUtilities.ParseISODateTime(command.Parameters["time"]));
     return commandResult;
 }
Exemplo n.º 6
0
        public void Test_InsertMotorbike_FillPark_ShouldInsertAllMotorbikes()
        {
            var park = new VehiclePark(2, 1);
            var motorbike = new Motorbike("CA1011AH", "John Smith", 1);
            var message = park.InsertMotorbike(motorbike, 1, 1, new DateTime(2015, 5, 10, 10, 30, 0));
            Assert.AreEqual("Motorbike parked successfully at place (1,1)", message);

            var otherMotorbike = new Motorbike("CA1022AH", "Jane Smith", 1);
            message = park.InsertMotorbike(otherMotorbike, 2, 1, new DateTime(2015, 5, 10, 12, 30, 0));
            Assert.AreEqual("Motorbike parked successfully at place (2,1)", message);
        }
        public void Test_FindVehiclesByOwner_SomeVehiclesMatch_ShouldSortCorrectly()
        {
            var park = new VehiclePark(3, 3);
            var first = new Car("CA1011AH", "John Smith", 1);
            park.InsertCar(first, 1, 1, new DateTime(2015, 5, 10, 10, 30, 0));
            var second = new Truck("CA2022AH", "John Smith", 1);
            park.InsertTruck(second, 1, 2, new DateTime(2015, 5, 10, 11, 30, 0));
            var third = new Truck("CA9999AH", "John Smith", 1);
            park.InsertTruck(third, 2, 1, new DateTime(2015, 5, 8, 11, 30, 0));
            var fourth = new Motorbike("CA1111AH", "John Smith", 1);
            park.InsertMotorbike(fourth, 2, 2, new DateTime(2015, 5, 8, 11, 30, 0));

            string message = park.FindVehiclesByOwner("John Smith");
            Assert.AreEqual(
                "Motorbike [CA1111AH], owned by John Smith\r\n" +
                "Parked at (2,2)\r\n" +
                "Truck [CA9999AH], owned by John Smith\r\n" +
                "Parked at (2,1)\r\n" +
                "Car [CA1011AH], owned by John Smith\r\n" +
                "Parked at (1,1)\r\n" +
                "Truck [CA2022AH], owned by John Smith\r\n" +
                "Parked at (1,2)",
                message);
        }