public void UnParkedVehicleShouldUpdateTheParkedVehicleStatus()
        {
            var         parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 3, SpotCount = 2
            };
            ParkingSpot newVacant = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 5, SpotCount = 6
            };
            ParkingSpot newVacant2 = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 1, SpotCount = 2
            };
            ParkingSpot newVacant3 = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 1, SpotCount = 10
            };
            var vehicle = new Vehicle()
            {
                RegistrationNumber = "XYZABC", VehicleType = VehicleTypes.HatchbackCar
            };

            parkingLot.ParkedVehicle(vehicle, spot).Should().BeTrue();
            parkingLot.UnParkedVehicle(vehicle);
            parkingLot.GetParkingSpotStatus(newVacant).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(newVacant2).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(spot).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(newVacant3).Should().Be(ParkingSpotStatus.Vacant);
        }
Пример #2
0
        public void UnParkVehicleShouldUpdateTheParkedVehicleStatus()
        {
            var         parkingLot = new ParkingLotCore(layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 3, SpotCount = 2
            };
            ParkingSpot newVacant = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 5, SpotCount = 6
            };
            ParkingSpot newVacant2 = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 2
            };
            ParkingSpot newVacant3 = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 10
            };
            var vehicle = new Vehicle()
            {
                VehicleNumber = "est", vehicleType = VehicleTypes.MotorCycle
            };

            parkingLot.ParkVehicle(vehicle, spot).Should().BeTrue();
            parkingLot.UnParkvehicle(vehicle);
            parkingLot.GetParkingSpotStatus(newVacant).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(newVacant2).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(spot).Should().Be(ParkingSpotStatus.Vacant);
            parkingLot.GetParkingSpotStatus(newVacant3).Should().Be(ParkingSpotStatus.Vacant);
        }
        public void TotalFreeSpotsAfterInitializingTest()
        {
            var parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            int freeSpots  = parkingLot.FreeSpots;

            freeSpots.Should().Be(60);
        }
        public void FreeSpotsAndTotalSpotsMustBeSameAfterInitializingTest()
        {
            var parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            int freeSpots  = parkingLot.FreeSpots;
            int totalSpots = parkingLot.TotalSpots;

            freeSpots.Should().Be(totalSpots);
        }
        public void GetParkingStatusShouldReturnVacant()
        {
            var         parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 3, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 1, SpotCount = 2
            };
            var result = parkingLot.GetParkingSpotStatus(spot);

            result.Should().Be(ParkingSpotStatus.Vacant);
        }
Пример #6
0
        public void GetOptimalSpotShouldReturnHigherFirstPositionForCar()
        {
            List <List <List <ParkingSpot> > > newLayout = new List <List <List <ParkingSpot> > >()
            {
                new List <List <ParkingSpot> > ()
                {
                    new List <ParkingSpot> ()
                    {
                        new ParkingSpot()
                        {
                            Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 10
                        },
                        new ParkingSpot()
                        {
                            Floor = 1, Row = 2, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 10
                        },
                        new ParkingSpot()
                        {
                            Floor = 1, Row = 3, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 10
                        }
                    },
                    new List <ParkingSpot> ()
                    {
                        new ParkingSpot()
                        {
                            Floor = 2, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Large, StartPosition = 1, SpotCount = 10
                        },
                        new ParkingSpot()
                        {
                            Floor = 2, Row = 2, ParkingSpotTypes = ParkingSpotTypes.Large, StartPosition = 1, SpotCount = 10
                        },
                        new ParkingSpot()
                        {
                            Floor = 2, Row = 2, ParkingSpotTypes = ParkingSpotTypes.Large, StartPosition = 1, SpotCount = 10
                        }
                    },
                }
            };
            var parkingLot = new ParkingLotCore(newLayout, new ParkingSpaceMapper());
            var vehicle    = new Vehicle()
            {
                VehicleNumber = "One", vehicleType = VehicleTypes.Car
            };
            var actual   = parkingLot.GetOptimalParkingSpot(vehicle);
            var expected = new ParkingSpot()
            {
                Floor = 2, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Large, StartPosition = 1, SpotCount = 1
            };

            actual.Should().BeEquivalentTo(expected);
        }
        public void ParkedVehicleShouldReturnTrue()
        {
            var         parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 3, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 1, SpotCount = 2
            };
            var vehicle = new Vehicle()
            {
                RegistrationNumber = "XYZABC", VehicleType = VehicleTypes.HatchbackCar
            };
            var actual = parkingLot.ParkedVehicle(vehicle, spot);

            actual.Should().BeTrue();
        }
Пример #8
0
        public void ParkVehicleShouldReturnTrue()
        {
            var         parkingLot = new ParkingLotCore(layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 2
            };
            var vehicle = new Vehicle()
            {
                VehicleNumber = "est", vehicleType = VehicleTypes.MotorCycle
            };
            var actual = parkingLot.ParkVehicle(vehicle, spot);

            actual.Should().BeTrue();
        }
        public void GetOptimalSpotShouldReturnHigherFirstPositionForSedan()
        {
            var parkingLot = new ParkingLotCore(LayoutHelper.NewLayout, new ParkingSpaceMapper());
            var vehicle    = new Vehicle()
            {
                RegistrationNumber = "STARK12345", VehicleType = VehicleTypes.Sedan
            };
            var actual   = parkingLot.GetOptimalParkingSpot(vehicle);
            var expected = new ParkingSpot()
            {
                Floor = 1, Row = 4, ParkingSpotTypes = ParkingSpotTypes.MiniTruck, StartPosition = 1, SpotCount = 1
            };

            actual.Should().BeEquivalentTo(expected);
        }
Пример #10
0
        public void GetOptimalSpotShouldReturnFirstPositionForCar()
        {
            var parkingLot = new ParkingLotCore(layout, new ParkingSpaceMapper());
            var vehicle    = new Vehicle()
            {
                VehicleNumber = "One", vehicleType = VehicleTypes.Car
            };
            var actual   = parkingLot.GetOptimalParkingSpot(vehicle);
            var expected = new ParkingSpot()
            {
                Floor = 2, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Compact, StartPosition = 1, SpotCount = 1
            };

            actual.Should().BeEquivalentTo(expected);
        }
Пример #11
0
        public void GetOptimalSpotShouldReturnNull()
        {
            var mockSpaceMapper = new Mock <IParkingSpaceMapper>();

            mockSpaceMapper.Setup(m => m.GetSmallestParkingSpaceRequired(It.IsAny <Vehicle>()))
            .Returns(new ParkingSpaceRequirment()
            {
                ParkingSpot = ParkingSpotTypes.Large, ParkingSpotsCount = 15
            });
            var parkingLot  = new ParkingLotCore(layout, mockSpaceMapper.Object);
            var parkingSpot = parkingLot.GetOptimalParkingSpot(new Vehicle()
            {
                VehicleNumber = "1", vehicleType = VehicleTypes.Bus
            });

            parkingSpot.Should().BeNull();
        }
        public void ParkShouldThrowException()
        {
            var         parkingLot = new ParkingLotCore(LayoutHelper.Layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Hatchback, StartPosition = 1, SpotCount = 2
            };
            var vehicle = new Vehicle()
            {
                RegistrationNumber = "XYZABC", VehicleType = VehicleTypes.HatchbackCar
            };
            var actual = parkingLot.ParkedVehicle(vehicle, spot);

            if (actual == true)
            {
                Action act = () => parkingLot.ParkedVehicle(vehicle, spot);
                act.Should().Throw <InvalidOperationException>();
            }
        }
Пример #13
0
        public void ParkShouldThrowException()
        {
            var         parkingLot = new ParkingLotCore(layout, new ParkingSpaceMapper());
            ParkingSpot spot       = new ParkingSpot {
                Floor = 1, Row = 1, ParkingSpotTypes = ParkingSpotTypes.Motorcycle, StartPosition = 1, SpotCount = 2
            };
            var vehicle = new Vehicle()
            {
                VehicleNumber = "est", vehicleType = VehicleTypes.MotorCycle
            };
            var actual = parkingLot.ParkVehicle(vehicle, spot);

            if (actual == true)
            {
                Action act = () => parkingLot.ParkVehicle(vehicle, spot);
                act.Should().Throw <InvalidOperationException>();
            }
        }