Пример #1
0
        public void Should_Super_Smart_Parking_Boy_Fetch_No_Car_Given_The_Ticket_Has_Been_Used()
        {
            //given
            var parkedCar  = new Car("N98245");
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var ticket = parkingBoy.Park(parkedCar, out _);

            parkingBoy.Fetch(ticket, out _);

            //when
            var car = parkingBoy.Fetch(ticket, out _);

            //then
            Assert.Null(car);
        }
Пример #2
0
        public void Should_Get_Error_Message_Unrecognized_parking_ticket_Given_A_Used_Ticket_When_Fetch_Car()
        {
            //given
            var parkedCar  = new Car("N98245");
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var ticket = parkingBoy.Park(parkedCar, out _);

            parkingBoy.Fetch(ticket, out _);

            //when
            var errorMessage = string.Empty;

            parkingBoy.Fetch(ticket, out errorMessage);

            //then
            Assert.Equal("Unrecognized parking ticket.", errorMessage);
        }
Пример #3
0
        public void Should_Super_Smart_Parking_Boy_Fetch_No_Cars_Given_The_No_Ticket()
        {
            //given
            var expectedCar = new Car("N98245");

            //when
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var car = parkingBoy.Fetch(null, out _);

            //then
            Assert.Null(car);
        }
Пример #4
0
        public void Should_Super_Smart_Parking_Boy_Fetch_A_Car_Using_Ticket()
        {
            //given
            var expectedCar = new Car("N98245");

            //when
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var ticket = parkingBoy.Park(expectedCar, out _);
            var car    = parkingBoy.Fetch(ticket, out _);

            //then
            Assert.Equal(expectedCar.GetType(), car.GetType());
        }
Пример #5
0
        public void Should_Get_Error_Message_Given_A_Null_Ticket_When_Fetch_Car()
        {
            //given
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });

            //when
            var errorMessage = string.Empty;

            parkingBoy.Fetch(null, out errorMessage);

            //then
            Assert.Equal("Please provide your parking ticket.", errorMessage);
        }
        public void Should_Fetch_Return_Car_With_Valid_ParkingTicket()
        {
            // given
            // given
            var parkedCar     = new Car("JAA8888");
            var parkingLot1   = new ParkingLot("ParkingLotOne");
            var parkingLot2   = new ParkingLot("ParkingLotOne");
            var parkingBoy    = new SuperSmartParkingBoy("Jack", parkingLot1, parkingLot2);
            var parkingTicket = parkingBoy.Park(parkedCar);

            // when
            var fetchedCar = parkingBoy.Fetch(parkingTicket);

            // then
            Assert.IsType <Car>(fetchedCar);
            Assert.Equal(fetchedCar, parkedCar);
        }
Пример #7
0
        public void Should_Get_Error_Message_Unrecognized_parking_ticket_Given_A_Wrong_Ticket_When_Fetch_Car()
        {
            //given
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot(10)
            });
            var wrongTicket = new Ticket("wrongNumber");

            //when
            var errorMessage = string.Empty;

            parkingBoy.Fetch(wrongTicket, out errorMessage);

            //then
            Assert.Equal("Unrecognized parking ticket.", errorMessage);
        }
Пример #8
0
        public void Should_Super_Smart_Parking_Boy_Park_Mutiple_Cars_And_Fetch_The_Right_Car_Using_Ticket()
        {
            //given
            var expectedCar = new Car("N98245");

            //when
            var parkingBoy = new SuperSmartParkingBoy(new List <ParkingLot>()
            {
                new ParkingLot()
            });
            var carList = new List <Car>()
            {
                new Car("car1"), new Car("car2"), new Car("car3")
            };

            carList.ForEach(car => parkingBoy.Park(car, out _));
            var ticket = parkingBoy.Park(expectedCar, out _);
            var car    = parkingBoy.Fetch(ticket, out _);

            //then
            Assert.Equal(expectedCar, car);
        }