예제 #1
0
        public void should_book_when_available()
        {
            availabilities.Setup(a => a.IsAvailable()).Returns(true);
            BookingOutcome outcome = booking.Book();

            Assert.True(outcome.IsSuccessful());
        }
        public void TheOneWhereThereAreNoRoomsAvailable()
        {
            RegisterAHotel()
            .WithId(hotelId)
            .WithAStandardRoomAt(101)
            .To(hotelService);

            bookingService.Book(employeeId, hotelId, Standard, Oct12th, Oct19th);

            Assert.Throws <RoomUnavailable>(() => bookingService.Book(employeeId, hotelId, Standard, Oct12th, Oct19th));
        }
        public void TheOneWhereISuccessfullyBookASingleRoom()
        {
            RegisterAHotel()
            .WithId(hotelId)
            .WithAStandardRoomAt(101)
            .To(hotelService);

            var bookingId = Guid.NewGuid();

            mockIdGenerator.Setup(it => it.GenerateId()).Returns(bookingId);

            var expectedBooking = aBooking()
                                  .WithId(bookingId)
                                  .WithEmployeeId(employeeId)
                                  .WithHotelId(hotelId)
                                  .From(Oct12th)
                                  .To(Oct19th)
                                  .Build();
            var actualBooking = bookingServiceWithStubbedIdGenerator.Book(employeeId, hotelId, Standard, Oct12th, Oct19th);

            Assert.Equal(expectedBooking, actualBooking);
        }
        public void CreateBookingIfRoomIsAvailable()
        {
            var booking = bookingService.Book(employeeId, hotelId, Standard, checkIn, checkOut);

            Assert.NotNull(booking);
        }
예제 #5
0
        public void MyOptions()
        {
            Helper.Print("My Options:");
            Helper.Print("\t1)Profile\n\t2)Offer a Ride\n\t3)Book a Ride\n\t4)Bookings Approval\n\t5)Check status of recent booking\n\t6)Past Offers\n\t7)Past Bookings\n\t8)Logout");
            int Option = Convert.ToInt16(Console.ReadLine());

            if (Option >= 1 && Option <= 8)
            {
                switch (Option)
                {
                case 1:
                    UserService.DisplayProfileDetails(SelectedUser);
                    MyOptions();
                    break;

                case 2:
                    Helper.Print("\nPlease enter the Details of your Car");
                    Helper.Print("\nEnter car Name:");
                    string name = Console.ReadLine();
                    Helper.Print("\nSelect your car type:");
                    int index = 0;
                    foreach (string str in Enum.GetNames(typeof(CarTypes)))
                    {
                        Helper.Print($"{++index}) { str}");
                    }
                    int      selectedType = Convert.ToInt16(Console.ReadLine());
                    CarTypes type         = (CarTypes)selectedType;
                    Helper.Print("\nEnter seat Capacity:");
                    int seatCapacity = Convert.ToInt16(Console.ReadLine());
                    BookingService.CarDetails(name, type, seatCapacity);
                    Helper.Print("\nEnter Ride fair(per Km):");
                    decimal rideFairPerKm = Convert.ToDecimal(Console.ReadLine());
                    Helper.Print("Please enter the number of checkpoints");
                    int checkPoints = Convert.ToInt16(Console.ReadLine());
                    Helper.Print("\nPlease enter your start point, Checkpoints,Destination and their respective distances(in Kms) to next area");
                    BookingService.CreateRideOffer(rideFairPerKm, checkPoints, SelectedUser);
                    Helper.Print("\n\tYour Ride offer has been registered");
                    Helper.Print("\n\tcurrently no one has booked your Ride\n\tWe will notify you once booking has been done");
                    Helper.Print("\tRedirecting to Main page\n");
                    MyOptions();
                    break;

                case 3:
                    Helper.Print("\nEnter Pickup Point:");
                    string pickPoint = Console.ReadLine();
                    Helper.Print("\nEnter Drop Point:");
                    string dropPoint = Console.ReadLine();
                    Helper.Print("\nEnter number of seats to book:");
                    int seats = Convert.ToInt16(Console.ReadLine());
                    BookingService.Book(pickPoint, dropPoint, seats, SelectedUser, out SelectedBooking);
                    bool available = BookingService.SearchAvailableRides(pickPoint, dropPoint, seats, SelectedUser, SelectedBooking);
                    if (available)
                    {
                        DisplayAvailableRides();
                        Helper.Print("\n\tSelect a option to book ride");
                        int rideOption = Convert.ToInt16(Console.ReadLine());
                        SelectedRide = BookingService.ReturnSelectedRideObject(rideOption);
                        DisplayConfirmationDetails();
                        BookingService.SaveBooking(SelectedRide, SelectedBooking, SelectedUser);
                        MyOptions();
                    }
                    else
                    {
                        Helper.Print("\n\tCurrently there are no ride offers available");
                        Helper.Print("\n\tplease check-in After sometime");
                        MyOptions();
                    }
                    break;

                case 4:
                    if (SelectedUser.LastRideOffered == null)
                    {
                        Helper.Print("No ride offered previously");
                    }
                    else
                    {
                        if (SelectedUser.LastRideOffered.Bookings.Count == 0)
                        {
                            Helper.Print($"No one has booked your offer yet");
                        }
                        else
                        {
                            Helper.Print("Showing the bookings of ride offered");
                            int bookingIndex = 0;
                            foreach (Booking rideBooking in SelectedUser.LastRideOffered.Bookings)
                            {
                                if (rideBooking.Status != BookingStatus.Rejected)
                                {
                                    Helper.Print($" {++bookingIndex} )\n\t Name : {rideBooking.BookingUser.Name}");
                                    Helper.Print($"\t Mobile : {rideBooking.BookingUser.Mobileno}");
                                    Helper.Print($"\t Pickup Point : {rideBooking.StartPoint}");
                                    Helper.Print($"\t Drop Point : {rideBooking.Destination}");
                                    Helper.Print($"\t Ride Fair : {rideBooking.RideFair}");
                                    Helper.Print("----------------------------------------------------------");
                                }
                            }
                            Helper.Print("Select the booking you want to approve or reject");
                            int bookingOption = Convert.ToInt16(Console.ReadLine());
                            Helper.Print("Do you want to approve or reject the booking:\n\t1)Approve\n\t2)Reject");
                            BookingStatus setStatus       = (BookingStatus)Convert.ToInt16(Console.ReadLine());
                            Booking       selectedBooking = BookingService.ReturnSelectedBooking(bookingOption, SelectedUser);
                            BookingService.SetStatusOfBooking(selectedBooking, setStatus, SelectedUser);
                        }
                    }
                    MyOptions();
                    break;

                case 5:
                    if (SelectedUser.LastBooking == null)
                    {
                        Helper.Print("No pending bookings available");
                    }
                    else
                    {
                        Helper.Print($"Booked ride was {SelectedUser.LastBooking.Status}");
                    }
                    MyOptions();
                    break;

                case 6:
                    DisplayPastOffers(SelectedUser);
                    MyOptions();
                    break;

                case 7:
                    DisplayPastBookings(SelectedUser);
                    MyOptions();
                    break;

                case 8:
                    Helper.Print("\t***YOU HAVE BEEN LOGOUT***");
                    break;
                }
            }
            else
            {
                Helper.Print($"Please enter a valid input");
                MyOptions();
            }
        }