Пример #1
0
        public void should_success_to_stop_car()
        {
            Park park = new Park(1);
            Car car = new Car("JP123");
            ParkingManager manager = new ParkingManager(new List<Park> { park }, null);

            manager.StopCar(car);

            Assert.Same(car, park.PickUpCar(car.CarNumber));
        }
Пример #2
0
        public void when_manager_have_one_empty_parking()
        {
            ParkingManager manager = new ParkingManager(new List<Park> { new Park(1) }, null);

            ParkingDirector director = new ParkingDirector(manager);

            string report = director.GenerateReport();
            string[] array = report.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            Assert.Equal(string.Format("{0}P 1 1", Utils.SpaceTwo), array[1]);
            Assert.Equal("M 1 1", array[0]);
        }
Пример #3
0
        public void should_success_to_ask_parkingboy_to_stop_car_when_one_boy()
        {
            Park park = new Park(1);
            Car car = new Car("JP123");
            ParkingBoy parkingBoy = new ParkingBoy(park);
            ParkingManager manager = new ParkingManager(null, new List<ParkingBoyBase> { parkingBoy });

            manager.StopCar(car);

            Assert.Same(car, park.PickUpCar(car.CarNumber));
        }
Пример #4
0
        public void when_manager_have_one_boy_with_no_parking()
        {
            var parkingBoy = new ParkingBoy();
            ParkingManager manager = new ParkingManager(null, new List<ParkingBoyBase> { parkingBoy });

            ParkingDirector director = new ParkingDirector(manager);

            string report = director.GenerateReport();
            string[] array = report.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            Assert.Equal(string.Format("{0}B 0 0", Utils.SpaceTwo), array[1]);
            Assert.Equal("M 0 0", array[0]);
        }
Пример #5
0
        public void should_success_to_stop_car_when_manager_empty_and_boys_full()
        {
            ParkingBoy parkingBoy = new ParkingBoy(new Park(0));
            ParkingManager manager = new ParkingManager(
                new List<Park> { new Park(1) },
                new List<ParkingBoyBase> { parkingBoy });
            Car car = new Car("JP123");

            manager.StopCar(car);

            Assert.Same(car, manager.PickUpCar(car.CarNumber));
        }
Пример #6
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));
        }
Пример #7
0
        public void should_parkingmanager_park_in_parkinglot_with_parkingboy()
        {
            var parkingBoy = ParkingBoyFactory.CreateParkingBoy(new Parkinglot());
            var parkingManager = new ParkingManager(
                ParkingBoyFactory.CreateSmartParkingBoy(new Parkinglot(0)),
                ParkingBoyFactory.CreateSuperParkingBoy(new Parkinglot(0)),
                parkingBoy,
                new Parkinglot(0));
            var car = new Car();

            var token = parkingManager.Park(car);

            Assert.Same(car, parkingBoy.Pick(token));
        }
Пример #8
0
        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));
        }
Пример #9
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]);
        }
Пример #10
0
 public ParkingDirector(ParkingManager parkingManager)
 {
     this.parkingManager = parkingManager;
 }
Пример #11
0
 public ParkingDirector(ParkingManager manager)
 {
     this.manager = manager;
 }