public void should_pick_right_car_when_mutiple_cars_parked()
        {
            Parkinglot parkinglot = new Parkinglot();
            parkinglot.Park(new Car());
            Car qq = new Car();
            var parkingTokenForQQ = parkinglot.Park(qq);
            parkinglot.Park(new Car());

            var carPickup = parkinglot.Pick(parkingTokenForQQ);

            Assert.Same(qq, carPickup);
        }
        public void should_parked_in_higher_vacancy_rate_when_parked_different_before_with_same_init()
        {
            var lowerVacancyRateParkinglot = new Parkinglot(2);
            lowerVacancyRateParkinglot.Park(new Car());
            lowerVacancyRateParkinglot.Park(new Car());
            var higherVacancyRateParkinglot = new Parkinglot(2);
            higherVacancyRateParkinglot.Park(new Car());
            var superParkingBoy = ParkingBoyFactory.CreateSuperParkingBoy(lowerVacancyRateParkinglot, higherVacancyRateParkinglot);
            var car = new Car();

            var parkingToken = superParkingBoy.Park(car);

            Assert.Same(car, higherVacancyRateParkinglot.Pick(parkingToken));
        }
        public void should_pick_car_after_the_car_parked()
        {
            Parkinglot parkinglot = new Parkinglot();

            Car carPickup = parkinglot.Pick(parkinglot.Park(new Car()));

            Assert.NotNull(carPickup);
        }
        public void should_park_in_high_available_stalls_when_parked_different_before_with_different_init()
        {
            var lessAvailableStalls = new Parkinglot(5);
            lessAvailableStalls.Park(new Car());
            lessAvailableStalls.Park(new Car());
            lessAvailableStalls.Park(new Car());
            var moreAvailableStall = new Parkinglot(4);
            moreAvailableStall.Park(new Car());
            var parkingBoy = ParkingBoyFactory.CreateSmartParkingBoy(
                lessAvailableStalls,
                moreAvailableStall);
            var car = new Car();

            var token = parkingBoy.Park(car);

            Assert.Same(car, moreAvailableStall.Pick(token));
        }
        public void should_print_report_when_manager_has_one_parkingboy_with_one_parklot()
        {
            var parkinglotWit1Car3Availiable = new Parkinglot(4);
            var parkingDirector = new ParkingDirector(new ParkingManager(ParkingBoyFactory.CreateParkingBoy(parkinglotWit1Car3Availiable)));

            parkinglotWit1Car3Availiable.Park(new Car());

            Assert.Equal("M 1 3\r\n  B 1 3\r\n    P 1 3\r\n", parkingDirector.Report());
        }
        public void should_print_report_when_manager_has_only_one_parkinglot()
        {
            var parkinglotWit1Car3Availiable = new Parkinglot(4);
            var parkingDirector = new ParkingDirector(new ParkingManager(parkinglotWit1Car3Availiable));

            parkinglotWit1Car3Availiable.Park(new Car());

            Assert.Equal("M 1 3\r\n  P 1 3\r\n", parkingDirector.Report());
        }
        public void should_not_pick_with_wrong_parkingToken()
        {
            var parkinglot = new Parkinglot();
            parkinglot.Park(new Car());

            var parkingToken = "123324";

            Assert.Null(parkinglot.Pick(parkingToken));
        }
        public void should_not_pickup_car_twice()
        {
            var parkinglot = new Parkinglot();
            var parkingToken = parkinglot.Park(new Car());
            parkinglot.Pick(parkingToken);

            var carPickUp = parkinglot.Pick(parkingToken);

            Assert.Null(carPickUp);
        }
        public void should_pick_car_when_there_are_two_parkinglot_parked()
        {
            var parkinglot = new Parkinglot();
            var parkingBoy = ParkingBoyFactory.CreateParkingBoy(new Parkinglot(), parkinglot);

            var car = new Car();
            var parkingToken = parkinglot.Park(car);

            Assert.Same(car, parkingBoy.Pick(parkingToken));
        }
        public void should_print_report_when_manager_has_only_two_parkinglot()
        {
            var firstParkinglotWit1Car3Availiable = new Parkinglot(4);
            var secondParkinglotWit1Car3Availiable = new Parkinglot(3);
            var parkingDirector = new ParkingDirector(new ParkingManager(firstParkinglotWit1Car3Availiable, secondParkinglotWit1Car3Availiable));

            firstParkinglotWit1Car3Availiable.Park(new Car());

            Assert.Equal("M 1 6\r\n  P 1 3\r\n  P 0 3\r\n", parkingDirector.Report());
        }
        public void should_failed_pick_when_all_parkinglots_are_full()
        {
            var firstParkinglot = new Parkinglot(1);
            firstParkinglot.Park(new Car());
            var secondParkinglot = new Parkinglot(1);
            secondParkinglot.Park(new Car());
            var smartParkingBoy = ParkingBoyFactory.CreateSmartParkingBoy(firstParkinglot, secondParkinglot);

            var parkingToken = smartParkingBoy.Park(new Car());

            Assert.Null(smartParkingBoy.Pick(parkingToken));
        }
        public void should_park_car_sequently_when_first_parkinglot_is_full_and_second_not()
        {
            var firstFullParkinglot = new Parkinglot(1);
            firstFullParkinglot.Park(new Car());
            var secondNotFullParkinglot = new Parkinglot(1);
            var parkingBoy = ParkingBoyFactory.CreateParkingBoy(firstFullParkinglot, secondNotFullParkinglot);

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

            Assert.Same(car, secondNotFullParkinglot.Pick(parkingToken));
        }
        public void should_failed_pick_car_after_parked_when_all_parkinglot_is_full()
        {
            var firstParkinglot = new Parkinglot(1);
            firstParkinglot.Park(new Car());
            var secondParkinglot = new Parkinglot(1);
            secondParkinglot.Park(new Car());
            var parkingBoy = ParkingBoyFactory.CreateParkingBoy(firstParkinglot);

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

            Assert.Null(parkingBoy.Pick(parkingToken));
        }
        public void should_pick_from_his_parkinglot()
        {
            var parkinglot = new Parkinglot(1);
            var parkingManager = new ParkingManager(
                ParkingBoyFactory.CreateParkingBoy(new Parkinglot(0)),
                ParkingBoyFactory.CreateSmartParkingBoy(new Parkinglot(0)),
                ParkingBoyFactory.CreateSuperParkingBoy(new Parkinglot(0)),
                parkinglot);
            var car = new Car();

            var token = parkinglot.Park(car);

            Assert.Same(car, parkingManager.Pick(token));
        }
        public void should_print_report_when_manager_has_two_parklots_and_one_parkingboy_with_two_parklot()
        {
            var parkinglotWith1Parked2Available = new Parkinglot(3);
            var parkinglotWith1Parked3Availible = new Parkinglot(4);
            var parkingDirector = new ParkingDirector(
                new ParkingManager(
                    new Parkinglot(3),
                    ParkingBoyFactory.CreateParkingBoy(parkinglotWith1Parked2Available, parkinglotWith1Parked3Availible),
                    new Parkinglot(4)
                    ));

            parkinglotWith1Parked2Available.Park(new Car());
            parkinglotWith1Parked3Availible.Park(new Car());

            Assert.Equal("M 2 12\r\n  P 0 3\r\n  B 2 5\r\n    P 1 2\r\n    P 1 3\r\n  P 0 4\r\n", parkingDirector.Report());
        }
        public void Should_pick_when_there_are_two_parkinglots()
        {
            var parkinglot = new Parkinglot();
            var superParkingBoy = ParkingBoyFactory.CreateSuperParkingBoy(new Parkinglot(), parkinglot);
            var car = new Car();
            var parkingToken = parkinglot.Park(car);

            var pickedCar = superParkingBoy.Pick(parkingToken);

            Assert.Same(car, pickedCar);
        }
        public void should_park_the_car_in_more_available_stalls_parkinglot()
        {
            var littleAvailableStallsParkinglot = new Parkinglot(2);
            littleAvailableStallsParkinglot.Park(new Car());
            var moreAvailableStallsParkinglot = new Parkinglot(4);
            moreAvailableStallsParkinglot.Park(new Car());
            var smartParkingBoy = ParkingBoyFactory.CreateSmartParkingBoy(littleAvailableStallsParkinglot, moreAvailableStallsParkinglot);
            var car = new Car();

            var parkingToken = smartParkingBoy.Park(car);

            Assert.Same(car, moreAvailableStallsParkinglot.Pick(parkingToken));
        }
        public void should_pick_failed_when_all_parkinglots_vacancy_rate_is_zero()
        {
            var firstParkinglot = new Parkinglot(1);
            firstParkinglot.Park(new Car());
            var secondParkinglot = new Parkinglot(1);
            secondParkinglot.Park(new Car());
            var superParkingBoy = ParkingBoyFactory.CreateSuperParkingBoy(firstParkinglot, secondParkinglot);

            var parkingToken = superParkingBoy.Park(new Car());

            Assert.Null(superParkingBoy.Pick(parkingToken));
        }
        public void should_pick_the_car_when_only_one_parkninglot()
        {
            var parkinglot = new Parkinglot();
            var smartParkingBoy = ParkingBoyFactory.CreateSmartParkingBoy(parkinglot);
            var car = new Car();

            var parkingToken = parkinglot.Park(car);
            var pickedCar = smartParkingBoy.Pick(parkingToken);

            Assert.Same(car, pickedCar);
        }