public void RegularSpotsFull_RegularClientCannotEnter()
        {
            // Arrange.
            var events = new Event[ParkingHouseInformation.Capacity -
                                   (int)(ParkingHouseInformation.Capacity * ParkingHouseInformation.PortionOfParkingSpotsReservedForContractClients)];

            for (int i = 0; i < events.Length; ++i)
            {
                events[i] = new EnteredParkingHouse {
                    Client = new Client {
                        Vehicle = new Vehicle()
                    }
                }
            }
            ;

            // Act & Assert.
            Test(
                Given(events),
                When(new EnterParkingHouse
            {
                Id     = _id,
                Client = _regularClient
            }),
                ThenFailWith <AllAvailableSpotsReserved>());
        }
    }
        public void CannotEnterParkingHouse_ParkingHouseFull()
        {
            // Arrange.
            var events = new Event[ParkingHouseInformation.Capacity];

            for (int i = 0; i < events.Length; ++i)
            {
                // We are adding contract clients to actually fill up ALL the parking spots (including reserved spots).
                events[i] = new EnteredParkingHouse {
                    Client = new ContractClient {
                        Vehicle = new Vehicle()
                    }
                }
            }
            ;

            // Act & Assert.
            Test(
                Given(events),
                When(new EnterParkingHouse
            {
                Id     = _id,
                Client = _regularClient
            }),
                ThenFailWith <ParkingHouseFull>());
        }
        public void RegularSpotsFull_ContractClientCanEnter()
        {
            // Arrange.
            var events = new Event[ParkingHouseInformation.Capacity -
                                   (int)(ParkingHouseInformation.Capacity * ParkingHouseInformation.PortionOfParkingSpotsReservedForContractClients)];

            for (int i = 0; i < events.Length; ++i)
            {
                events[i] = new EnteredParkingHouse {
                    Client = new Client {
                        Vehicle = new Vehicle()
                    }
                }
            }
            ;

            // Act & Assert.
            Test(
                Given(events),
                When(new EnterParkingHouse
            {
                Id     = _id,
                Client = _contractClient
            }),
                Then(new EnteredParkingHouse
            {
                Id       = _id,
                Client   = _contractClient,
                DateTime = InitialDateTime
            }));
        }
Esempio n. 4
0
        public void Apply(EnteredParkingHouse e)
        {
            var spotType = DecideWhichSpotToTake(e.Client);

            switch (spotType)
            {
            case ParkingSpotType.Regular:
                _regularSpotsTaken++;
                break;

            case ParkingSpotType.Reserved:
                _reservedSpotsTaken++;
                break;
            }
            _clients.Add(e.Client, new ClientParkingData {
                ParkingSpotType = spotType, DateTimeEntered = e.DateTime
            });
        }