コード例 #1
0
        public void should_can_stop_and_pick_up_when_two_park_both_have_empty_parking_position()
        {
            Park park = new Park(1);
            Car car = new Car("JP123");
            ParkingBoy boy = new ParkingBoy(park, new Park(1));

            Assert.True(boy.StopCar(car));
            Assert.Same(car, park.PickUpCar(car.CarNumber));
        }
コード例 #2
0
        public void should_can_stop_and_pick_up_when_first_park_full_and_second_park_empty()
        {
            Park firstPark = new Park(0);
            Park secondPark = new Park(1);
            Car car = new Car("JP123");
            ParkingBoy boy = new ParkingBoy(firstPark, secondPark);

            Assert.True(boy.StopCar(car));
            Assert.Same(car, secondPark.PickUpCar(car.CarNumber));
        }
コード例 #3
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]);
        }