Beispiel #1
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));
        }
Beispiel #2
0
        given_a_parking_lot_and_a_parking_boy_then_parking_boy_park_a_car_and_pick_the_car_then_parking_boy_cannot_pick_the_car
            ()
        {
            var parkingLot = new OOParkingLot(1);
            var parkingBoy = new ParkingBoy(parkingLot);
            var myCar      = new Car("a");

            var carId = parkingBoy.Park(myCar);

            parkingBoy.Pick(carId);

            Assert.AreEqual(null, parkingBoy.Pick(carId));
        }
Beispiel #3
0
        given_two_parking_lot_when_parking_boy_park_a_car_and_pick_the_car_then_parking_boy_cannot_pick_a_car
            ()
        {
            var firstParkingLot  = new OOParkingLot(1);
            var secondParkingLot = new OOParkingLot(1);
            var parkingBoy       = new ParkingBoy(firstParkingLot, secondParkingLot);
            var car = new Car("car");

            var carId = parkingBoy.Park(car);

            parkingBoy.Pick(carId);

            Assert.AreSame(null, parkingBoy.Pick(carId));
        }
Beispiel #4
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));
        }
Beispiel #5
0
        void should_can_not_pick_any_car_when_the_car_is_not_exist()

        {
            var parkingBoy = new ParkingBoy();

            Assert.Throws <NotFoundException>(() => parkingBoy.Pick("123"));
        }
Beispiel #6
0
        void should_not_pick_a_car_when_the_car_has_been_picked_by_parking_boy()
        {
            const string carId      = "ABC123";
            var          car        = new Car(carId);
            var          parkingLot = new ParkingLot();
            var          parkingBoy = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });

            parkingBoy.Park(car);
            Car pickedCar = parkingBoy.Pick(carId);

            Assert.Same(car, pickedCar);

            pickedCar = parkingBoy.Pick(carId);
            Assert.Null(pickedCar);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void should_not_pick_one_car_while_no_car_parking()
        {
            var       parkingLot   = new ParkingLot(4);
            var       parkingBoy   = new ParkingBoy(new[] { parkingLot });
            const int illegalToken = 0;

            var pickCar = parkingBoy.Pick(illegalToken);

            Assert.Same(null, pickCar);
        }
Beispiel #9
0
        given_a_parking_lot_and_a_parking_boy_when_park_a_car_in_parking_lot_directly_then_parking_boy_can_pick_the_car
            ()
        {
            var parkingLot = new OOParkingLot(1);
            var parkingBoy = new ParkingBoy(parkingLot);

            var myCar = new Car("a");
            var carId = parkingLot.Park(myCar);

            Assert.AreSame(myCar, parkingBoy.Pick(carId));
        }
Beispiel #10
0
        public void should_return_when_make_park_boy_pick_a_car_given_the_ticket_is_created_by_mine()
        {
            var parkingLot = new ParkingLot(1);
            var car        = new Car();
            var ticket     = parkingLot.Park(car);
            var boy        = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });

            Assert.Equal(car, boy.Pick(ticket));
        }
Beispiel #11
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));
        }
        public void should_pick_the_same_car_after_parked_car()
        {
            var parkingLot = new ParkingLot(1);
            var parkingBoy = new ParkingBoy(parkingLot);
            var car        = new Car();
            var token      = parkingBoy.Park(car);

            var pickedCar = parkingBoy.Pick(token);

            pickedCar.Should().BeSameAs(car);
        }
Beispiel #13
0
        public void should_pick_the_same_car_with_the_ticket_generated_by_parkingboy()
        {
            List <ParkingLot> parkingLots = new List <ParkingLot>()
            {
                new ParkingLot(1)
            };
            ParkingBoy parkingBoy = new ParkingBoy(parkingLots);
            Car        car        = new Car();
            var        ticket     = parkingBoy.Park(car);

            Assert.Same(car, parkingBoy.Pick(ticket));
        }
Beispiel #14
0
        public void should_return_same_car_when_smart_parkingboy_parking_car_then_smart_parkingboy_pick()
        {
            var smartParkingBoy = new ParkingBoy(new List <ParkingLot> {
                new ParkingLot(1)
            }, ParkingBoyType.Smart);
            var car   = new Car();
            var carId = smartParkingBoy.Park(car);

            var pickedCar = smartParkingBoy.Pick(carId);

            Assert.AreSame(car, pickedCar);
        }
Beispiel #15
0
        public void should_pick_one_car()
        {
            var parkingLot = new ParkingLot(4);
            var parkingBoy = new ParkingBoy(new[] { parkingLot });
            var car        = new Car();

            var token = parkingBoy.Park(car);

            var pickCar = parkingBoy.Pick(token);

            Assert.Same(car, pickCar);
        }
Beispiel #16
0
        public void should_can_pick_one_car_with_parking_boy()
        {
            var parkingLot = new ParkingLot(1);
            var parkingBoy = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });
            var car = new Car();

            var carId = parkingBoy.Park(car);

            Assert.AreSame(car, parkingBoy.Pick(carId));
        }
Beispiel #17
0
        given_a_full_parking_lot_and_a_parking_boy_which_managed_by_parking_mananger_with_one_space_parking_lot_when_parking_manager_park_the_car_then_parking_boy_could_pick_the_car
            ()
        {
            var emptyParkinglot = new OOParkingLot(0);
            var parkinglot      = new OOParkingLot(1);
            var parkingBoy      = new ParkingBoy(parkinglot);
            var manager         = new ParkingManager(emptyParkinglot, parkingBoy);
            var car             = new Car("car");

            var carId = manager.Park(car);

            Assert.AreSame(car, parkingBoy.Pick(carId));
        }
Beispiel #18
0
        public void should_pick_the_same_car_using_the_ticket_generated_by_parkinglot()
        {
            ParkingLot        parkingLot  = new ParkingLot(1);
            List <ParkingLot> parkingLots = new List <ParkingLot>()
            {
                parkingLot
            };
            ParkingBoy parkingBoy = new ParkingBoy(parkingLots);
            Car        car        = new Car();
            var        ticket     = parkingLot.Park(car);

            Assert.Same(car, parkingBoy.Pick(ticket));
        }
Beispiel #19
0
        public void should_pick_car_from_parking_lot_2_by_common_parking_boy_if_the_car_is_in_parking_lot_2()
        {
            var parkingLot1 = new ParkingLot(1);
            var parkingLot2 = new ParkingLot(1);
            var parkingBoy  = new ParkingBoy(new List <ParkingLot>()
            {
                parkingLot1, parkingLot2
            });
            var car    = new Car();
            var ticket = parkingLot2.Park(car);

            Assert.Equal(car, parkingBoy.Pick(ticket));
        }
Beispiel #20
0
        public void should_throw_InvalidTicketException_when_make_park_boy_pick_a_car_given_a_invalid_ticket()
        {
            var parkingLot = new ParkingLot(1);
            var boy        = new ParkingBoy(new List <ParkingLot> {
                parkingLot
            });
            var car    = new Car();
            var ticket = boy.Park(car);

            var exception = Assert.Throws <InvalidTicketException>(() => boy.Pick(new object()));

            Assert.Equal("invalid ticket", exception.Message);
        }
Beispiel #21
0
        public void should_be_able_to_pick_car_by_common_parking_boy()
        {
            var car        = new Car();
            var parkingLot = new ParkingLot(1);
            var parkingBoy = new ParkingBoy(new List <ParkingLot>()
            {
                parkingLot
            });

            var ticket = parkingLot.Park(car);

            Assert.Equal(car, parkingBoy.Pick(ticket));
        }
Beispiel #22
0
        public void should_throw_NotFoundException_when_make_park_boy_pick_a_car_given_the_car_not_in_parking_lots_of_managed_by_boy()
        {
            var parkingLot1 = new ParkingLot(1);
            var parkingLot2 = new ParkingLot(1);
            var boy         = new ParkingBoy(new List <ParkingLot> {
                parkingLot1
            });
            var car    = new Car();
            var ticket = parkingLot2.Park(car);

            var exception = Assert.Throws <InvalidTicketException>(() => boy.Pick(ticket));

            Assert.Equal("invalid ticket", exception.Message);
        }
Beispiel #23
0
        public void should_not_pick_car_when_ticket_doesnt_match()
        {
            ParkingLot        lot         = new ParkingLot(0);
            List <ParkingLot> parkingLots = new List <ParkingLot>()
            {
                lot
            };
            ParkingBoy parkingBoy = new ParkingBoy(parkingLots);
            Car        car        = new Car();

            parkingBoy.Park(car);
            var ticket = new Ticket();

            Assert.Null(parkingBoy.Pick(ticket));
        }
Beispiel #24
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);
        }
        public void should_pick_the_right_car_successfully_when_manages_two_parking_lot()
        {
            var oneParkingLot = new ParkingLotBuilder()
                                .WithCapacity(1)
                                .WithOccupiedParkingSpace(1)
                                .Create();
            var anotherParkingLot = new ParkingLot(1);
            var parkingBoy        = new ParkingBoy(oneParkingLot, anotherParkingLot);
            var car   = new Car();
            var token = parkingBoy.Park(car);

            var pickedCar = parkingBoy.Pick(token);

            pickedCar.Should().BeSameAs(car);
        }
Beispiel #26
0
        public void should_pick_one_car_when_have_two_parking_lots()
        {
            var parkingLotOne = new ParkingLot(4);
            var parkingLotTwo = new ParkingLot(4);
            var parkingBoy    = new ParkingBoy(new[] { parkingLotOne, parkingLotTwo });

            TakeAllParkingSpaceOfParkingLot(parkingLotOne);
            var car = new Car();

            var token = parkingBoy.Park(car);

            var pickCar = parkingBoy.Pick(token);

            Assert.Same(car, pickCar);
        }