Exemple #1
0
        public void CustomerCreationTest()
        {
            CardDetails details = new CardDetails("01912664311", "10/11", "10/13");
            Customer customer = new Customer("Customer", "*****@*****.**", details);

            Assert.AreEqual("Customer ([email protected])", customer.ToString());
        }
Exemple #2
0
        public void CardDetailsCreationTest()
        {
            string number = "2664311";
            string issueDate = "10/13";
            string expiryDate = "10/15";

            CardDetails details = new CardDetails(number, issueDate, expiryDate);

            Assert.AreEqual(details.Number, number);
            Assert.AreEqual(details.IssueDate, issueDate);
            Assert.AreEqual(details.ExpiryDate, expiryDate);
        }
Exemple #3
0
        public void TestBookingCollisions()
        {
            CardDetails details = new CardDetails("01912664311", "10/11", "10/13");
            Customer customer = new Customer("Customer", "*****@*****.**", details);
            Room room = Room.Get(1);

            Booking booking1 = new Booking(new DateTime(2012, 4, 1), new DateTime(2012, 4, 5), customer, room);
            Booking bookingConflict = new Booking(new DateTime(2012, 4, 3), new DateTime(2012, 4, 6), customer, room);
            Booking bookingNoConflict = new Booking(new DateTime(2012, 4, 9), new DateTime(2012, 4, 12), customer, room);
            Booking bookingDifferentRoom = new Booking(new DateTime(2012, 4, 3), new DateTime(2012, 4, 6), customer,
                                                       Room.Get(2));
            Booking bookingDifferentRoomNoConflict = new Booking(new DateTime(2012, 4, 12), new DateTime(2012, 4, 19),
                                                                 customer, Room.Get(2));

            Assert.IsTrue(booking1.Contains(bookingConflict));
            Assert.IsTrue(bookingConflict.Contains(booking1));
            Assert.IsFalse(booking1.Contains(bookingNoConflict));
            Assert.IsFalse(booking1.Contains(bookingDifferentRoom));
            Assert.IsFalse(booking1.Contains(bookingDifferentRoomNoConflict));
        }
Exemple #4
0
 public Customer(string name, string email, CardDetails cardDetails)
 {
     Name = name;
     Email = email;
     CardDetails = cardDetails;
 }
Exemple #5
0
 public Customer(string name, string email, CardDetails cardDetails)
 {
     Name        = name;
     Email       = email;
     CardDetails = cardDetails;
 }
Exemple #6
0
        public void TestBookingCreation()
        {
            CardDetails details = new CardDetails("01912664311", "10/11", "10/13");
            Customer customer = new Customer("Customer", "*****@*****.**", details);
            Room room = Room.Get(1);
            DateTime start = new DateTime(2012, 4, 1);
            DateTime end = new DateTime(2012, 4, 5);
            Booking booking = new Booking(start, end, customer, room);

            Assert.AreEqual(string.Format("Room {0} for {1} from {2} to {3}", room.Number, customer, start.ToShortDateString(),
                                 end.ToShortDateString()), booking.ToString());
        }
Exemple #7
0
        /// <summary>
        /// Main loop method
        /// </summary>
        /// <returns>True for continue looping, false otherwise.</returns>
        public bool Loop()
        {
            //Begin

            Out("Welcome to Old Frenchay Inn!");
            var seeRooms = Ask("Would you like to see our rooms?");

            if (!seeRooms)
            {
                Out("Okay then.");
                return(true);
            }

            PrintRoomTypeList();

            //Selecting room type

            Out("Which room type would you like to book?");
            var type = GetRoomTypeFromUser();

            //Selecting date

            Out("Sweet. When from? We only have april.");
            var chosenStartDate = GetStartDateFromUser();


            Out("Okay. How long for? You can't leave april. Sorry.");
            var chosenNumberOfDays = GetNumberOfDaysFromUser(chosenStartDate);

            var booking = MakeBooking(chosenStartDate, chosenNumberOfDays, type);

            if (booking == null)
            {
                Out("Oh! Sorry, we don't have that time free.");
                return(true);
            }

            //Accepting price

            double price = booking.GetPrice();

            Out(string.Format("Okay, that'll be £{0}.", price));

            if (!Ask("That okay?"))
            {
                Out("Okay. There's a cardboard box just down the road.");
                return(true);
            }

            //Taking name

            Out("Sweet. I'm just gonna need your name: ", false);
            string name = In();

            Out("Your email address: ", false);
            string email = In();

            //Finishing booking

            Out("Thanks. Gimme a sec to make your booking", false);
            DoLongWork();

            Booking.AddBooking(booking);
            Out(string.Format("Okay, your booking number is {0}.", booking.ReservationNumber));

            //Taking card details

            Out("Let's just finalise this and we're all done, okay? Card number: ", false);
            var cardNumber = GetCardNumber();

            Out("And that was issued on:", false);
            string issueDate = In();

            Out("And expires on:", false);
            string expiryDate = In();

            Out("Gotcha. Let's just finalise this", false);
            DoLongWork();

            var details  = new CardDetails(cardNumber, issueDate, expiryDate);
            var customer = new Customer(name, email, details);

            booking.Customer = customer;

            Out(string.Format("Alrighty, we're taking the payment now. I can confirm your booking is {0}.", booking));

            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Main loop method
        /// </summary>
        /// <returns>True for continue looping, false otherwise.</returns>
        public bool Loop()
        {
            //Begin

            Out("Welcome to Old Frenchay Inn!");
            var seeRooms = Ask("Would you like to see our rooms?");
            if (!seeRooms){
                Out("Okay then.");
                return true;
            }

            PrintRoomTypeList();

            //Selecting room type

            Out("Which room type would you like to book?");
            var type = GetRoomTypeFromUser();

            //Selecting date

            Out("Sweet. When from? We only have april.");
            var chosenStartDate = GetStartDateFromUser();

            Out("Okay. How long for? You can't leave april. Sorry.");
            var chosenNumberOfDays = GetNumberOfDaysFromUser(chosenStartDate);

            var booking = MakeBooking(chosenStartDate, chosenNumberOfDays, type);
            if (booking == null){
                Out("Oh! Sorry, we don't have that time free.");
                return true;
            }

            //Accepting price

            double price = booking.GetPrice();
            Out(string.Format("Okay, that'll be £{0}.", price));

            if (!Ask("That okay?")){
                Out("Okay. There's a cardboard box just down the road.");
                return true;
            }

            //Taking name

            Out("Sweet. I'm just gonna need your name: ", false);
            string name = In();
            Out("Your email address: ", false);
            string email = In();

            //Finishing booking

            Out("Thanks. Gimme a sec to make your booking", false);
            DoLongWork();

            Booking.AddBooking(booking);
            Out(string.Format("Okay, your booking number is {0}.", booking.ReservationNumber));

            //Taking card details

            Out("Let's just finalise this and we're all done, okay? Card number: ", false);
            var cardNumber = GetCardNumber();
            Out("And that was issued on:", false);
            string issueDate = In();
            Out("And expires on:", false);
            string expiryDate = In();
            Out("Gotcha. Let's just finalise this", false);
            DoLongWork();

            var details = new CardDetails(cardNumber, issueDate, expiryDate);
            var customer = new Customer(name, email, details);

            booking.Customer = customer;

            Out(string.Format("Alrighty, we're taking the payment now. I can confirm your booking is {0}.", booking));

            return true;
        }