コード例 #1
0
 public void Unpark(Car parkedCar, Token token)
 {
     if(FindCar(token) == null)
         throw new Exception("Car is not parked");
     _parkedCarData.Remove(token);
     _parkedCarCount--;
     ParkingAvailabiltyStatus = ParkingAvailabiltyStatusEnum.Available;
 }
コード例 #2
0
        public void ShouldBeAbleToFindMyParkedCar()
        {
            var token1 = _parkingLot.Park(_car);
            var parkedCar1 = _parkingLot.FindCar(token1);
            Assert.AreEqual(_car, parkedCar1);

            var car2 = new Car("MH12AA1111");
            var token2 = _parkingLot.Park(car2);
            var parkedCar2 = _parkingLot.FindCar(token2);
            Assert.AreEqual(car2, parkedCar2);
        }
コード例 #3
0
 public Token Park(Car car)
 {
     if (ParkingAvailabiltyStatus == ParkingAvailabiltyStatusEnum.Available)
     {
         Token newToken = new Token(car.CarNumber);
         this._parkedCarData.Add(newToken, car);
         _parkedCarCount++;
         if (_parkedCarCount == _parkingLotCapacity)
             ParkingAvailabiltyStatus = ParkingAvailabiltyStatusEnum.NotAvailable;
         return newToken;
     }
     throw new Exception("Parking is full ! Sorry !");
 }
コード例 #4
0
 public void Setup()
 {
     _parkingLot = new ParkingLot();
     _car = new Car("MH-12FV7622");
 }