Exemplo n.º 1
0
        public void GetNextEmptyLot_Returns_Closest_Empty_Lot()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(2);
            Assert.Equal(1, parkingLotManager.GetNextEmptyLot());
        }
Exemplo n.º 2
0
        public void GetNextEmptyLot_Returns_Zero_If_No_Parking_Available()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(1);
            parkingLotManager.GetNextEmptyLot();
            Assert.Equal(0, parkingLotManager.GetNextEmptyLot());
        }
Exemplo n.º 3
0
        public void ParkCar_Uses_Empty_Parking_Lot()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);
            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number1", Color = "Test-Color1"
            }, parkingLotManager.GetNextEmptyLot());
            Assert.Equal(2, parkingLotManager.GetNextEmptyLot());
        }
        public void Handle(string input, ParkingLotManager parkingLotManager)
        {
            var tokens = input.Split(' ');

            if (tokens.Length == 2 && int.TryParse(tokens[1], out var size))
            {
                parkingLotManager.SetEmptyLots(size);
                Console.WriteLine($"Created a parking lot with {size} slots");
            }
        }
Exemplo n.º 5
0
        public void LeaveParking_Adjusts_Parking_Lot()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(1);
            parkingLotManager.GetNextEmptyLot();
            Assert.Equal(0, parkingLotManager.GetNextEmptyLot());

            parkingLotManager.LeaveParking(1);
            Assert.Equal(1, parkingLotManager.GetNextEmptyLot());
        }
Exemplo n.º 6
0
        public void SetEmptyLots_Creates_Five_Empty_ParkingLot()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(5);

            for (var i = 1; i <= 5; i++)
            {
                Assert.Equal(i, parkingLotManager.GetNextEmptyLot());
            }
        }
Exemplo n.º 7
0
        public void GetRegistrationNumbersByCarColor_Returns_Registration_After_Parking_A_Car()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);
            var car = new Car {
                RegistrationNumber = "Test-Registration-Number", Color = "Test-Color"
            };

            parkingLotManager.ParkCar(car, 1);

            Assert.Equal(car.RegistrationNumber, parkingLotManager.GetRegistrationNumbersByCarColor("Test-Color").First());
        }
Exemplo n.º 8
0
        public void GetRegistrationNumbersByCarColor_Returns_Empty_Registration_After_Leaving_Parking()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);
            var car1 = new Car {
                RegistrationNumber = "Test-Registration-Number1", Color = "Test-Color"
            };

            parkingLotManager.ParkCar(car1, 1);
            parkingLotManager.LeaveParking(1);

            Assert.Empty(parkingLotManager.GetRegistrationNumbersByCarColor("Test-Color"));
        }
Exemplo n.º 9
0
        public void ParkCar_Not_Possible_When_Parking_Lots_Are_Full()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);

            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number1", Color = "Test-Color1"
            }, parkingLotManager.GetNextEmptyLot());
            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number2", Color = "Test-Color2"
            }, parkingLotManager.GetNextEmptyLot());
            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number3", Color = "Test-Color3"
            }, parkingLotManager.GetNextEmptyLot());

            Assert.Equal(0, parkingLotManager.GetNextEmptyLot());
        }
Exemplo n.º 10
0
        public void GetNextEmptyLot_Returns_Closest_Empty_Lot_After_Adjusting_Car_Leaving()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);

            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number1", Color = "Test-Color1"
            }, parkingLotManager.GetNextEmptyLot());
            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number2", Color = "Test-Color2"
            }, parkingLotManager.GetNextEmptyLot());
            parkingLotManager.ParkCar(new Car {
                RegistrationNumber = "Test-Registration-Number3", Color = "Test-Color3"
            }, parkingLotManager.GetNextEmptyLot());

            parkingLotManager.LeaveParking(2);
            parkingLotManager.LeaveParking(3);

            Assert.Equal(2, parkingLotManager.GetNextEmptyLot());
        }
Exemplo n.º 11
0
        public void GetRegistrationNumbersByCarColor_Returns_Registrations_After_Parking_Multiple_Car()
        {
            var parkingLotManager = new ParkingLotManager();

            parkingLotManager.SetEmptyLots(3);
            var car1 = new Car {
                RegistrationNumber = "Test-Registration-Number1", Color = "Test-Color"
            };
            var car2 = new Car {
                RegistrationNumber = "Test-Registration-Number2", Color = "Test-Color"
            };
            var car3 = new Car {
                RegistrationNumber = "Test-Registration-Number3", Color = "Test-Color"
            };

            parkingLotManager.ParkCar(car1, 1);
            parkingLotManager.ParkCar(car2, 1);
            parkingLotManager.ParkCar(car3, 1);

            Assert.Equal(new List <string> {
                car1.RegistrationNumber, car2.RegistrationNumber, car3.RegistrationNumber
            }, parkingLotManager.GetRegistrationNumbersByCarColor("Test-Color"));
        }