public void More_test_cases_SuperSmartParkingBoy_Should_park_cars_to_more_positionRate_parkingLot(int parkingCapacity1, int parkingCapacity2, int parkingCapacity3)
        {
            //given
            var parkingLots = new List <ParkingLot>()
            {
                { new ParkingLot(parkingCapacity1) }, { new ParkingLot(parkingCapacity2) }, { new ParkingLot(parkingCapacity3) }
            };
            var superSmartParkingBoy = new SuperSmartParkingBoy();
            var parkingBoy           = new ParkingBoy();

            //when
            for (int i = 0; i < 2; i++)
            {
                parkingBoy.Park(i.ToString(), parkingLots[1]);
                parkingBoy.Park(i.ToString(), parkingLots[2]);
            }

            var numberPlate      = "XX2345";
            var parkingTicket    = superSmartParkingBoy.Park(numberPlate, parkingLots);
            var expectParkingLot = parkingLots[0];

            //then
            Assert.NotEmpty(parkingTicket);
            Assert.Contains <string>("XX2345", expectParkingLot.ParkingCarsList);
        }
Exemple #2
0
        public void should_can_pack_one_car_when_parking_boy_has_one_full_packinglot_and_unfull_packinglot()
        {
            var secondParkingLot = new ParkingLot(1);
            var parkingBoy       = new ParkingBoy(new List <ParkingLot> {
                new ParkingLot(1), secondParkingLot
            });

            parkingBoy.Park(new Car());

            var car   = new Car();
            var carId = parkingBoy.Park(car);

            Assert.AreSame(car, secondParkingLot.Pick(carId));
        }
Exemple #3
0
        public void should_get_null_if_try_to_park_a_car_when_all_parking_lots_are_full()
        {
            var parkingLot1 = new ParkingLot(1);
            var parkingLot2 = new ParkingLot(1);
            var parkingBoy  = new ParkingBoy(new List <ParkingLot>()
            {
                parkingLot1, parkingLot2
            });

            parkingBoy.Park(new Car());
            parkingBoy.Park(new Car());

            Assert.Null(parkingBoy.Park(new Car()));
        }
        public void should_return_same_car_when_use_second_parking_lot_pick_car()
        {
            var secondParkingLot = new ParkingLot(2);
            var smartParkingBoy  = new ParkingBoy(new List <ParkingLot> {
                new ParkingLot(2), secondParkingLot
            }, ParkingBoyType.Smart);

            smartParkingBoy.Park(new Car());

            Car car   = new Car();
            var carId = smartParkingBoy.Park(car);

            Assert.AreSame(car, secondParkingLot.Pick(carId));
        }
Exemple #5
0
        public void Should_Return_no_parkingTicket_when_park_a_parked_car()
        {
            //given
            var parkingLot = new ParkingLot();
            var parkingBoy = new ParkingBoy();
            //when
            string numberPlate = "XX2345";

            parkingBoy.Park(numberPlate, parkingLot);
            var actual = parkingBoy.Park(numberPlate, parkingLot);

            //then
            Assert.Empty(actual);
        }
Exemple #6
0
        public void should_pick_corresponding_car_with_specific_ticket()
        {
            List <ParkingLot> parkingLots = new List <ParkingLot>()
            {
                new ParkingLot(2)
            };
            ParkingBoy parkingBoy = new ParkingBoy(parkingLots);
            Car        carA       = new Car();
            Car        carB       = new Car();
            var        ticketA    = parkingBoy.Park(carA);
            var        ticketB    = parkingBoy.Park(carB);

            Assert.Same(carA, parkingBoy.Pick(ticketA));
            Assert.Same(carB, parkingBoy.Pick(ticketB));
        }
Exemple #7
0
        void should_pick_the_car_when_the_first_parking_lot_is_full_and_park_the_car()
        {
            var parkingBoy = new ParkingBoy(new List <ParkingLot> {
                new ParkingLot(1), new ParkingLot(1)
            });
            const string carId = "ABC123";
            var          car   = new Car(carId);

            parkingBoy.Park(new Car("not care"));
            parkingBoy.Park(car);

            Car pickedCar = parkingBoy.Pick(carId);

            Assert.Same(car, pickedCar);
        }
Exemple #8
0
        public void should_keep_order_when_make_park_boy_park_a_car_given_boy_own_two_parking_lot_first_parking_lot_has_two_spaces()
        {
            var firsLot   = new ParkingLot(2);
            var secondLot = new ParkingLot(0);
            var lots      = new List <ParkingLot>
            {
                firsLot, secondLot
            };
            var boy = new ParkingBoy(lots);

            boy.Park(new Car());
            boy.Park(new Car());

            Assert.Equal(2, firsLot.CurrentCount());
            Assert.Equal(0, secondLot.CurrentCount());
        }
        public void Should_ParkingBoy_Return_Null_When_Both_Parkinglots_Are_Full(string plateNumber, string parkingTicket)
        {
            //Given
            var    boy         = new ParkingBoy("Jack");
            var    car         = new Car(plateNumber);
            string message     = string.Empty;
            var    parkingLots = new List <CarLot <string, Car> >()
            {
                LotInitialize.FillLotWithCars(10),
                LotInitialize.FillLotWithCars(10),
            };
            string expectedTicket = null;
            int    expectedLoadsOfFirstParkinglot  = 10;
            int    expectedLoadsOfSecondParkinglot = 10;

            //When
            string actualTicket = boy.Park(car, parkingLots, out message);
            var    actualLoadsOfFirstParkinglot  = parkingLots[0].Count;
            var    actualLoadsOfSecondParkinglot = parkingLots[1].Count;

            //Then
            Assert.Equal(expectedTicket, actualTicket);
            Assert.Equal(expectedLoadsOfFirstParkinglot, actualLoadsOfFirstParkinglot);
            Assert.Equal(expectedLoadsOfSecondParkinglot, actualLoadsOfSecondParkinglot);
        }
Exemple #10
0
        void should_not_park_car_when_all_parking_lot_are_full()
        {
            var firstParkingLot  = new ParkingLot(1);
            var secondParkingLot = new ParkingLot(1);
            var parkingBoy       = new ParkingBoy(new List <ParkingLot> {
                firstParkingLot, secondParkingLot
            });

            parkingBoy.Park(new Car("Not care1"));
            ParkCarResult parkCarResult = parkingBoy.Park(new Car("Not care2"));

            Assert.Equal(ParkCarResult.Success, parkCarResult);

            parkCarResult = parkingBoy.Park(new Car("Not care3"));

            Assert.Equal(ParkCarResult.NoParkingSpace, parkCarResult);
        }
Exemple #11
0
        void should_park_the_car_in_the_secondary_parking_lot_when_the_first_one_is_full()
        {
            var firstParkingLot  = new ParkingLot(1);
            var secondParkingLot = new ParkingLot(1);
            var parkingBoy       = new ParkingBoy(new List <ParkingLot> {
                firstParkingLot, secondParkingLot
            });
            const string carId = "ABC123";
            var          car   = new Car(carId);

            parkingBoy.Park(new Car("Not care"));
            parkingBoy.Park(car);

            Car pickedCar = secondParkingLot.Pick(carId);

            Assert.Same(car, pickedCar);
        }
        void should_return_error_message_when_given_a_car_to_parking_boy_while_parking_lots_are_full()
        {
            var parkingBoy = new ParkingBoy(new List <ParkingLot>
            {
                new ParkingLot(parkingLotSize),
                new ParkingLot(parkingLotSize)
            });

            for (var i = 0; i < parkingLotSize * 2; i++)
            {
                parkingBoy.Park(new Car());
            }

            var error = Assert.Throws <Exception>(() => parkingBoy.Park(new Car()));

            Assert.Equal("Parking lots are full!", error.Message);
        }
Exemple #13
0
        public void Should_Return_Null_Tickt_When_Park_The_Parked_Car()
        {
            //given
            var parkingBoy = new ParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var car = new Car("car1");

            parkingBoy.Park(car, out _);

            //when
            var ticket = parkingBoy.Park(car, out _);

            //then
            Assert.Null(ticket);
        }
Exemple #14
0
        public void Should_Park_The_Car_To_Mutiple_Parking_Lots_And_Park_To_Next_One_If_Previous_Is_Full()
        {
            //given
            var parkingLot2 = new ParkingLot(2);

            var parkingBoy = new ParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot(1), parkingLot2
            });

            //when
            var ticket1 = parkingBoy.Park(new Car("car1"), out _);
            var ticket2 = parkingBoy.Park(new Car("car2"), out _);

            //then
            Assert.Contains(ticket2.TicketNumber, parkingLot2.Tickets);
        }
Exemple #15
0
        public void Car_Should_not_be_parked_if_parkinglot_is_full()
        {
            //given
            var parkingLot = new ParkingLot();
            var parkingBoy = new ParkingBoy();
            //when
            var numberPlate = "XX2345";

            for (int i = 0; i < 10; i++)
            {
                parkingBoy.Park(i.ToString(), parkingLot);
            }

            var actual = parkingBoy.Park(numberPlate, parkingLot);

            //then
            Assert.Empty(actual);
        }
Exemple #16
0
        void should_can_not_pick_the_same_car_twice()
        {
            var parkingBoy = new ParkingBoy(new ParkingLot(10));
            var token      = parkingBoy.Park(new Car());

            parkingBoy.Pick(token);

            Assert.Throws <NotFoundException>(() => parkingBoy.Pick(token));
        }
Exemple #17
0
        public void Should_Park_No_Car_Given_Parking_Lot_Has_No_Position()
        {
            //given
            var parkedCar  = new Car("N98245");
            var parkingBoy = new ParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot(1)
            });

            parkingBoy.Park(parkedCar, out _);

            //when
            var newCar    = new Car("A982453");
            var newTicket = parkingBoy.Park(newCar, out _);

            //then
            Assert.Null(newTicket);
        }
        void should_return_a_ticket_when_given_a_car_to_parking_boy()
        {
            var parkingBoy = new ParkingBoy(new List <ParkingLot>
            {
                new ParkingLot(parkingLotSize)
            });
            var ticket = parkingBoy.Park(new Car());

            Assert.NotNull(ticket);
        }
        void should_return_error_message_when_given_a_car_to_parking_boy_while_parking_lots_managed_by_him_are_full()
        {
            var notManagedParkingLot = new ParkingLot(parkingLotSize);
            var managedParkingLot    = new ParkingLot(parkingLotSize);
            var parkingBoy           = new ParkingBoy(new List <ParkingLot>
            {
                managedParkingLot
            });

            for (var i = 0; i < parkingLotSize; i++)
            {
                parkingBoy.Park(new Car());
            }

            Assert.NotNull(notManagedParkingLot.Park(new Car()));
            var error = Assert.Throws <Exception>(() => parkingBoy.Park(new Car()));

            Assert.Equal("Parking lots are full!", error.Message);
        }
Exemple #20
0
        void should_can_pick_the_car_by_parking_boy_when_parking_boy_park_a_car()
        {
            var parkingBoy = new ParkingBoy(new ParkingLot(10));
            var car        = new Car();
            var token      = parkingBoy.Park(car);

            var pickedCar = parkingBoy.Pick(token);

            Assert.Same(car, pickedCar);
        }
Exemple #21
0
        public void should_park_cars_in_order_using_multiple_parking_lot()
        {
            var car1        = new Car();
            var car2        = new Car();
            var parkingLot1 = new ParkingLot(1);
            var parkingLot2 = new ParkingLot(1);
            var parkingBoy  = new ParkingBoy(new List <ParkingLot>()
            {
                parkingLot1, parkingLot2
            });

            var ticket1 = parkingBoy.Park(car1);
            var ticket2 = parkingBoy.Park(car2);

            Assert.Null(parkingLot1.Pick(ticket2));
            Assert.Null(parkingLot2.Pick(ticket1));
            Assert.Equal(car1, parkingLot1.Pick(ticket1));
            Assert.Equal(car2, parkingLot2.Pick(ticket2));
        }
Exemple #22
0
        public void should_park_one_car()
        {
            var parkingLot = new ParkingLot(4);
            var parkingBoy = new ParkingBoy(new[] { parkingLot });
            var car        = new Car();

            var token = parkingBoy.Park(car);

            Assert.Same(car, parkingLot.Pick(token));
        }
Exemple #23
0
        public void should_throw_NoSpaceException_when_make_park_boy_park_a_car_given_parking_lot_no_space()
        {
            var parkingLot = new ParkingLot(0);
            var boy        = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });
            var exception = Assert.Throws <NoSpaceException>(() => boy.Park(new Car()));

            Assert.Equal("no space", exception.Message);
        }
Exemple #24
0
        public void should_return_ticket_when_make_park_boy_park_a_car_given_parking_lot_has_only_one_space()
        {
            var parkingLot = new ParkingLot(1);
            var boy        = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });
            var ticket = boy.Park(new Car());

            Assert.NotNull(ticket);
        }
Exemple #25
0
        public void should_return_car_when_make_park_boy_pick_a_car_given_a_correct_ticket()
        {
            var parkingLot = new ParkingLot(1);
            var boy        = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });
            var car    = new Car();
            var ticket = boy.Park(car);

            Assert.Equal(car, boy.Pick(ticket));
        }
Exemple #26
0
        public void Should_ParkingBoyPark_Return_No_Ticket_Given_Parked_Car()
        {
            //Given
            var    boy         = new ParkingBoy("Jack");
            string message     = string.Empty;
            var    parkingLots = new List <CarLot <string, Car> >()
            {
                LotInitialize.FillLotWithCars(3),
            };
            var car = new Car("RJ_12784");

            boy.Park(car, parkingLots, out message);
            string expected = null;

            //When
            var result = boy.Park(car, parkingLots, out message);

            //Then
            Assert.Equal(expected, result);
        }
Exemple #27
0
        public void Return_a_parkingTicket_when_park()
        {
            //given
            var parkingLot = new ParkingLot();
            var parkingBoy = new ParkingBoy();
            //when
            var numberPlate = "XX2345";

            //then
            Assert.IsType <string>(parkingBoy.Park(numberPlate, parkingLot));
        }
Exemple #28
0
        void should_can_pick_the_car_from_the_first_has_space_parking_lot()
        {
            var parkingLot = new ParkingLot(10);
            var parkingBoy = new ParkingBoy(new ParkingLot(0), parkingLot, new ParkingLot(10));
            var car        = new Car();
            var token      = parkingBoy.Park(car);

            var pickedCar = parkingLot.Pick(token);

            Assert.Same(car, pickedCar);
        }
Exemple #29
0
            public void should_park_a_car_into_a_parking_lot_which_has_space_and_get_a_ticket()
            {
                var list = new List <ParkingLot> {
                    new ParkingLot(_capacity)
                };
                var parkingBoy = new ParkingBoy(list);

                var ticket = parkingBoy.Park(new Car());

                Assert.NotNull(ticket);
            }
Exemple #30
0
        public void Sould_return_something_when_park()
        {
            //given
            var parkingLot = new ParkingLot();
            var parkingBoy = new ParkingBoy();
            //when
            var numberPlate = "XX2345";

            //then
            Assert.NotNull(parkingBoy.Park(numberPlate, parkingLot));
        }