public void ParkingBoy_Should_Return_Null_Given_No_Ticket_Or_Wrong_Ticket()
        {
            //given
            var car         = new Car("car_1");
            var newCustomer = new Customer("customer_1", car);
            var parkingLot  = new ParkingLot("parkingLot_1", 3);
            var parkingBoy  = new ParkingBoy("parkingBoy_1", parkingLot);

            //when
            newCustomer.PassCarToParkingBoy(parkingBoy);
            var resultOfNoTicket    = parkingBoy.FetchCar(null, out _);
            var resultOfWrongTicket = parkingBoy.FetchCar(new ParkingTicket("another_parkingBoy", "new_Car", "new_Customer", "another_ParkingLot"), out _);

            //then
            Assert.Null(resultOfNoTicket);
            Assert.Null(resultOfWrongTicket);
        }
        public void Should_return_null_when_use_a_used_parking_ticket_to_fetch_a_car()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var car           = new Car();
            var parkingTicket = parkingBoy.ParkCar(car, out string errorMessage);

            parkingBoy.FetchCar(parkingTicket, out string errorMessage1);
            // when
            var actualCar = parkingBoy.FetchCar(parkingTicket, out string errorMessage2);

            // then
            Assert.Null(actualCar);
        }
Exemplo n.º 3
0
        public void ParkingBoy_Should_Add_Error_Message_Given_Parked_Ticket()
        {
            //given
            var car         = new Car("car_1");
            var newCustomer = new Customer("customer_1", car);
            var parkingLot  = new ParkingLot.ParkingLot("parkingLot_1", 3);
            var parkingBoy  = new ParkingBoy("parkingBoy_1", parkingLot);

            //when
            var parkedTicket = parkingBoy.ParkCar(car, out _);

            parkingBoy.FetchCar(parkedTicket, out _);
            parkingBoy.FetchCar(parkedTicket, out var errorMessage);
            var expectedMessage = "Unrecognized parking ticket.";

            //then
            Assert.Equal(expectedMessage, errorMessage);
        }
        public void Should_return_no_car_and_generate_error_message_Unrecognized_parking_ticket_when_customer_provide_a_used_ticket()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var car           = new Car();
            var parkingTicket = parkingBoy.ParkCar(car, out string errorMessagePark);

            parkingBoy.FetchCar(parkingTicket, out string errorMessage1);
            // when
            string errorMessage;
            var    actualCar = parkingBoy.FetchCar(parkingTicket, out errorMessage);

            // then
            Assert.Null(actualCar);
            Assert.Equal("Unrecognized parking ticket.", errorMessage);
        }
Exemplo n.º 5
0
        public void ParkingBoy_Should_Add_Error_Message_Given_No_Ticket()
        {
            //given
            var parkingLot = new ParkingLot.ParkingLot("parkingLot_1", 3);
            var parkingBoy = new ParkingBoy("parkingBoy_1", parkingLot);

            //when
            parkingBoy.FetchCar(null, out var errorMessage);
            var expectedMessage = "Please provide your parking ticket.";

            //then
            Assert.Equal(expectedMessage, errorMessage);
        }
        public void Should_return_the_car_when_use_correct_parking_ticket_to_fetch_the_car()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var expectedCar   = new Car();
            var parkingTicket = parkingBoy.ParkCar(expectedCar, out string errorMessagePark);
            // when
            var actualCar = parkingBoy.FetchCar(parkingTicket, out string errorMessage);

            // then
            Assert.Equal(expectedCar, actualCar);
        }
        public void Should_return_null_when_given_not_provided_ticket_to_fetch_car()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var car           = new Car();
            var parkingTicket = parkingBoy.ParkCar(car, out string errorMessagePark);
            // when
            var actualCar = parkingBoy.FetchCar(new ParkingTicket(parkingTicket.ParkingLotId, parkingTicket.CarId + 1), out string errorMessage);

            // then
            Assert.Null(actualCar);
        }
Exemplo n.º 8
0
        public void ParkingBoy_Should_Add_Error_Message_Given_Wrong_Ticket()
        {
            //given
            var car         = new Car("car_1");
            var newCustomer = new Customer("customer_1", car);
            var parkingLot  = new ParkingLot.ParkingLot("parkingLot_1", 3);
            var parkingBoy  = new ParkingBoy("parkingBoy_1", parkingLot);

            //when
            newCustomer.PassCarToParkingBoy(parkingBoy);
            var resultOfWrongTicket = parkingBoy.FetchCar(new ParkingTicket("another_parkingBoy", "new_Car", "new_Customer", "another_ParkingLot"), out var errorMessage);
            var expectedMessage     = "Unrecognized parking ticket.";

            //then
            Assert.Equal(expectedMessage, errorMessage);
        }
        public void Should_return_no_car_and_generate_error_message_Please_provide_your_parking_ticket_when_customer_does_not_provide_a_ticket()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var car           = new Car();
            var parkingTicket = parkingBoy.ParkCar(car, out string errorMessagePark);
            // when
            string errorMessage;
            var    actualCar = parkingBoy.FetchCar(null, out errorMessage);

            // then
            Assert.Null(actualCar);
            Assert.Equal("Please provide your parking ticket.", errorMessage);
        }
        public void Should_get_the_right_car_when_add_multiple_cars()
        {
            // given
            List <ParkingLot> parkingLotList = new List <ParkingLot> {
                new ParkingLot(0), new ParkingLot(1)
            };
            var parkingBoy    = new ParkingBoy(parkingLotList);
            var expectedCar   = new Car();
            var anotherCar    = new Car();
            var parkingTicket = parkingBoy.ParkCar(expectedCar, out string errorMessagePark1);

            parkingBoy.ParkCar(anotherCar, out string errorMessagePark2);
            // when
            var actualCar            = parkingBoy.FetchCar(parkingTicket, out string errorMessage);
            var isFetchedTheRightCar = expectedCar.Equals(actualCar) && !anotherCar.Equals(actualCar);

            // then
            Assert.True(isFetchedTheRightCar);
        }
        public void ShouldGiveErrorMessageWhenTicketIsNull()
        {
            // given
            Car car = new Car("CARA111");

            // when
            string            errorMessage, positionErrorMessage;
            ParkingLot        parkingLot1 = new ParkingLot("A");
            ParkingLot        parkingLot2 = new ParkingLot("B");
            List <ParkingLot> parkingLots = new List <ParkingLot>();

            parkingLots.Add(parkingLot1);
            parkingLots.Add(parkingLot2);
            ParkingBoy    parkingBoy    = new ParkingBoy(parkingLots);
            ParkingTicket parkingTicket = parkingBoy.ParkingCar(car, out positionErrorMessage);
            Car           actual        = parkingBoy.FetchCar(null, out errorMessage);

            // then
            Assert.Equal("Please provide your parking ticket.", errorMessage);
        }
        public void ShouldFetchACarUsingParkingTicket()
        {
            // given
            Car car = new Car("CARA111");

            // when
            string            positionErrorMessage, errorMessage;
            ParkingLot        parkingLot1 = new ParkingLot("A");
            ParkingLot        parkingLot2 = new ParkingLot("B");
            List <ParkingLot> parkingLots = new List <ParkingLot>();

            parkingLots.Add(parkingLot1);
            parkingLots.Add(parkingLot2);
            ParkingBoy    parkingBoy    = new ParkingBoy(parkingLots);
            ParkingTicket parkingTicket = parkingBoy.ParkingCar(car, out positionErrorMessage);
            Car           actual        = parkingBoy.FetchCar(parkingTicket, out errorMessage);

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