예제 #1
0
        public void should_stopped_to_more_empty_poisition_park_when_two_parks_have_different_empty_position()
        {
            Park lessEmptyPoisitionPark = new Park(1);
            Park moreEmptyPoisitionPark = new Park(2);
            Car car = new Car("JP123");
            SmartParkingBoy boy = new SmartParkingBoy(lessEmptyPoisitionPark, moreEmptyPoisitionPark);

            boy.StopCar(car);

            Assert.Same(car, moreEmptyPoisitionPark.PickUpCar(car.CarNumber));
        }
예제 #2
0
        public void should_stopped_to_first_park_when_two_parks_have_same_empty_position()
        {
            Park firstPark = new Park(1);
            Park secondPark = new Park(1);
            Car car = new Car("JP123");
            SmartParkingBoy boy = new SmartParkingBoy(firstPark, secondPark);

            boy.StopCar(car);

            Assert.Same(car, firstPark.PickUpCar(car.CarNumber));
        }
예제 #3
0
        public void should_not_pick_up_car_when_repeat_pick_up()
        {
            Park firstPark = new Park(1);
            Park secondPark = new Park(1);
            Car car = new Car("JP123");
            SmartParkingBoy boy = new SmartParkingBoy(firstPark, secondPark);

            boy.StopCar(car);
            boy.PickUpCar(car.CarNumber);

            Assert.Same(null, boy.PickUpCar(car.CarNumber));
        }
예제 #4
0
        public void should_success_to_ask_parkingboy_to_pick_car_when_two_boys()
        {
            ParkingBoy parkingBoy = new ParkingBoy(new Park(1));
            SmartParkingBoy smartParkingBoy = new SmartParkingBoy(new Park(1));
            Car car = new Car("JP123");

            ParkingManager manager = new ParkingManager(null, new List<ParkingBoyBase> { parkingBoy, smartParkingBoy });

            manager.StopCar(car);

            Assert.Same(car, manager.PickUpCar(car.CarNumber));
        }
예제 #5
0
        public void when_manager_have_one_boy_with_first_boy_have_full_parking_and_second_boy_have_one_empty()
        {
            var parkingBoy = new ParkingBoy(new Park(1));
            parkingBoy.StopCar(new Car("JP123"));
            var smartBoy = new SmartParkingBoy(new Park(1));
            ParkingManager manager = new ParkingManager(null, new List<ParkingBoyBase> { parkingBoy, smartBoy });

            ParkingDirector director = new ParkingDirector(manager);

            string report = director.GenerateReport();
            string[] array = report.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            var spaceTwo = Utils.SpaceTwo;
            Assert.Equal(string.Format("{0}B 0 1", spaceTwo), array[1]);
            var spaceFour = Utils.SpaceFour;
            Assert.Equal(string.Format("{0}P 0 1", spaceFour), array[2]);
            Assert.Equal(string.Format("{0}B 1 1", spaceTwo), array[3]);
            Assert.Equal(string.Format("{0}P 1 1", spaceFour), array[4]);
            Assert.Equal("M 1 2", array[0]);
        }