public void Should_return_no_car_when_ticket_is_used()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    ticket     = boy.Park(car, out errorMessage);
            Car    fetchedCar = boy.Fetch(ticket, out errorMessage);

            Car tryFetchedCar = boy.Fetch(ticket, out errorMessage);

            Assert.Null(tryFetchedCar);
        }
        public void Should_return_error_message_when_ticket_is_already_used_for_fetching_car()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };

            string errorMessage;
            var    ticket = boy.Park(car, out errorMessage);

            var fetchedCar = boy.Fetch(ticket, out errorMessage);
            var newFetched = boy.Fetch(ticket, out errorMessage);

            Assert.Equal("Unrecognized parking ticket.", errorMessage);
        }
        public void Should_return_no_car_when_ticket_is_not_provided()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    correctTicket = boy.Park(car, out errorMessage);
            Ticket wrongTicket   = null;

            var fetchedCarWithWrongTicket   = boy.Fetch(wrongTicket, out errorMessage);
            var fetchedCarWithCorrectTicket = boy.Fetch(correctTicket, out errorMessage);

            Assert.Null(fetchedCarWithWrongTicket);
            Assert.Equal(car, fetchedCarWithCorrectTicket);
        }
        public void Should_return_no_car_when_ticket_is_wrong_with_boyId()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string message;
            var    correctTicket = boy.Park(car, out message);
            var    wrongTicket   = new Ticket(car.GetLicenseNumber(), lot.GetLocation(), boy.Id + 1);

            var fetchedCarWithWrongTicket   = boy.Fetch(wrongTicket, out message);
            var fetchedCarWithCorrectTicket = boy.Fetch(correctTicket, out message);

            Assert.Null(fetchedCarWithWrongTicket);
            Assert.Equal(car, fetchedCarWithCorrectTicket);
        }
        public void Should_return_correct_car_when_multiple_tickets_are_provided()
        {
            var boy  = new Boy();
            var lot  = new Lot();
            var car1 = new Car("123");
            var car2 = new Car("456");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    ticket1 = boy.Park(car1, out errorMessage);
            var    ticket2 = boy.Park(car2, out errorMessage);

            Car fetchedCar1 = boy.Fetch(ticket1, out errorMessage);
            Car fetchedCar2 = boy.Fetch(ticket2, out errorMessage);

            Assert.Equal(car1.GetLicenseNumber(), fetchedCar1.GetLicenseNumber());
            Assert.Equal(car2.GetLicenseNumber(), fetchedCar2.GetLicenseNumber());
        }
        public void Should_return_correct_car_when_ticket_is_provided()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    ticket = boy.Park(car, out errorMessage);

            Car fetchedCar = boy.Fetch(ticket, out errorMessage);

            Assert.Equal(car.GetLicenseNumber(), fetchedCar.GetLicenseNumber());
        }
        public void Should_return_error_message_when_ticket_is_not_provided_for_fetching_car()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };

            string errorMessage;
            var    ticket     = boy.Park(car, out errorMessage);
            var    fetchedCar = boy.Fetch(null, out errorMessage);

            Assert.Equal("Please provide your parking ticket.", errorMessage);
        }
        public void Should_return_error_message_when_ticket_is_wrong_with_boyId_for_fetching_car()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    ticket = boy.Park(car, out errorMessage);

            var wrongTicket = new Ticket(car.GetLicenseNumber(), lot.GetLocation(), boy.Id + 1);
            var fetchedCar  = boy.Fetch(wrongTicket, out errorMessage);

            Assert.Equal("Unrecognized parking ticket.", errorMessage);
        }
        public void Should_have_changed_number_of_position_when_car_is_fetched()
        {
            var boy = new Boy();
            var lot = new Lot();
            var car = new Car("123");

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    ticket = boy.Park(car, out errorMessage);
            var    initialLeftPosition = lot.LeftPosition;

            var fetchedCar      = boy.Fetch(ticket, out errorMessage);
            var newLeftPosition = lot.LeftPosition;

            Assert.Equal(1, newLeftPosition - initialLeftPosition);
        }
        public void Should_not_park_car_and_return_no_ticket_when_positions_are_all_occupied()
        {
            var boy = new Boy();
            var lot = new Lot(capacity: 1);

            boy.Lots = new Lot[] { lot };
            string errorMessage;
            var    car1   = new Car("123");
            var    ticket = boy.Park(car1, out errorMessage);
            var    car2   = new Car("456");

            var tryTicket = boy.Park(car2, out errorMessage);

            Assert.Null(tryTicket);
            Assert.False(lot.HaveCar(car2));

            Car tryFetchedCar = boy.Fetch(ticket, out errorMessage);
            var newTryTicket  = boy.Park(car2, out errorMessage);

            Assert.NotNull(newTryTicket);
            Assert.Equal(newTryTicket.GetLicenseNumber(), car2.GetLicenseNumber());
            Assert.True(lot.HaveCar(car2));
        }