Ejemplo n.º 1
0
        // Returns the right guest if guest exist
        public void GetGuest_Method_Returns_The_Right_Guest_If_It_Does_Exist_In_The_List()
        {
            Booking aBooking = new Booking();
            //Create Guests
            Guest Guest1 = new Guest();

            Guest1.Name = "zero";
            aBooking.AddGuest(Guest1);

            Guest Guest2 = new Guest();

            Guest2.Name = "one";
            aBooking.AddGuest(Guest2);

            Guest Guest3 = new Guest();

            Guest3.Name = "two";
            aBooking.AddGuest(Guest3);


            int   index    = 0;
            Guest GuestOne = aBooking.GetGuest(index); //Should return the guest at index 0 (Guest1)

            Assert.AreEqual(Guest1.Name, GuestOne.Name, "Method returns the right guest");
        }
Ejemplo n.º 2
0
        public void GetCost_Method_Calculates_Cost_Of_Bookings_Correctly()
        {
            Booking aBooking = new Booking();

            // Booking for 2 nights
            aBooking.ArrivalDate   = DateTime.Parse("2000-01-01");
            aBooking.DepartureDate = DateTime.Parse("2000-01-03");

            //Create 2 guests
            Guest guest1 = new Guest();

            guest1.Age = 12; //Create a guest (child charged at £30.00/night)
            aBooking.AddGuest(guest1);
            Guest guest2 = new Guest();

            guest2.Age = 32; //Create a guest (adult charged at £50.00/night)
            aBooking.AddGuest(guest2);

            //Create Extras
            Breakfast breakfast1 = new Breakfast(); //Breakfast charged at £5.00 per guest per night
            CarHire   carhire1   = new CarHire();   //CarHire charged at £50.00/day

            //Car hire booked for 1 day
            carhire1.StartDate  = DateTime.Parse("2000-01-01");
            carhire1.ReturnDate = DateTime.Parse("2000-01-02");
            aBooking.AddExtra(breakfast1);
            aBooking.AddExtra(carhire1);


            double expected   = 230.00;             //expected cost for booking
            double calculated = aBooking.GetCost(); //Cost returned from the GetCost method

            Assert.AreEqual(expected, calculated, "GetCost method calculated booking costs correctly!");
        }
Ejemplo n.º 3
0
        // Returns a null guest if guest cannot be found in the list
        public void GetGuest_Method_Returns_Null_If_Guest_Does_Not_Exist()
        {
            Booking aBooking = new Booking();
            //Create Guests
            Guest Guest1 = new Guest();
            Guest Guest2 = new Guest();

            //Add guests to booking list
            aBooking.AddGuest(Guest1);
            aBooking.AddGuest(Guest2);

            int   index  = 2;
            Guest Guest3 = aBooking.GetGuest(index); //Should return a null Guest

            Assert.AreEqual(Guest3, null, "Guest can not be found! (null)");
        }
Ejemplo n.º 4
0
        // Throws exception if guest with the provided index does not exist
        public void RemoveGuest_Method_Removes_Guest_If_Guest_Does_Exist()
        {
            Booking aBooking = new Booking();
            //Create Guest
            Guest Guest1 = new Guest();
            Guest Guest2 = new Guest();

            //Add guest to booking list
            aBooking.AddGuest(Guest1);
            aBooking.AddGuest(Guest2);

            int index = 1;

            aBooking.RemoveGuest(index); // Should remove the Guest at index 1
            Assert.AreEqual(aBooking.Guests.Count, 1, "Guest was removed successfuly");
        }
Ejemplo n.º 5
0
        //Method throw exception when adding a new guest to alist with 4 guests (maximum number of guests = 4)
        public void Add_Guest_Fail_When_4_Guests_Already_In_The_List()
        {
            Booking aBooking = new Booking();
            //Create 5 guests
            Guest Guest1 = new Guest();
            Guest Guest2 = new Guest();
            Guest Guest3 = new Guest();
            Guest Guest4 = new Guest();
            Guest Guest5 = new Guest();

            //Add guests to booking list
            aBooking.AddGuest(Guest1);
            aBooking.AddGuest(Guest2);
            aBooking.AddGuest(Guest3);
            aBooking.AddGuest(Guest4);
            aBooking.AddGuest(Guest5); //This line should throw an Argument exception
        }
Ejemplo n.º 6
0
        public void GuestTest()
        {
            Booking target      = new Booking();
            Guest   targetGuest = new Guest("Andrei", "045619", 20);

            target.AddGuest(targetGuest);
            Assert.AreEqual(targetGuest, target.GuestList[0]);
        }
Ejemplo n.º 7
0
        //Method will pass if Guest is added to Booking guest list successfuly
        public void Add_Guests_Working_Correctly()
        {
            Booking aBooking = new Booking();
            Guest   aGuest   = new Guest();

            aBooking.AddGuest(aGuest);
            //The number of guests in the guest list must be 1 at this point
            Assert.AreEqual(aBooking.Guests.Count, 1, "Guest sucessfuly added to booking!");
        }
Ejemplo n.º 8
0
        public void canCalculateBasePrice_6()
        {//add breakfast for more days
            //calculate with people
            //create test Booking and test guests
            createTestBooking2();
            createTestGuest();
            createTestGuest2();
            //add guests to the guest list of the booking
            testBooking2.AddGuest(testGuest);
            testBooking2.AddGuest(testGuest2);

            //expected
            //(60(chalet per night) * 5(number of nights)) + (2(people) * 5(number of nights) * 25(night per person))
            //+ 5(breakfast price) * 5(number of nights) * 2(people)
            double expectedPrice = 1150;

            //run
            double actualPrice = testBooking2.CalculatePrice(testBooking2.numberOfGuests(), testBooking2.numberOfNights(), 0); //baseprice

            //add extra
            testBooking2.Breakfast = true;
            Breakfast_add breakfast = new Breakfast_add();

            breakfast.AddTo(testBooking);
            actualPrice += breakfast.CalculatePrice(testBooking2.numberOfGuests(), testBooking2.numberOfNights(), 0); //carhire days is 0, only calculating base price

            //test
            Assert.AreEqual(expectedPrice, actualPrice, "Booking price is not correct, price calculation FAILED.");
        }
Ejemplo n.º 9
0
        // Throws exception if guest with the provided index does not exist
        public void RemoveGuest_Method_Throws_Exception_If_Guest_Does_Not_Exist()
        {
            Booking aBooking = new Booking();
            //Create Guest
            Guest Guest1 = new Guest();

            //Add guest to booking list
            aBooking.AddGuest(Guest1);

            int index = 2;

            aBooking.RemoveGuest(index); // Should throw exception since guest at index 2 does not exist
        }
Ejemplo n.º 10
0
        public void canCalculateBasePrice_3()
        {//calculate with people
            //create test Booking and test guests
            createTestBooking();
            createTestGuest();
            createTestGuest2();
            //add guests to the guest list of the booking
            testBooking.AddGuest(testGuest);
            testBooking.AddGuest(testGuest2);

            //expected
            //(60(chalet per night) * 1(number of nights)) + (2(people) * 1(number of nights) * 25(night per person))
            double expectedPrice = 110;

            //run
            double actualPrice = testBooking.CalculatePrice(testBooking.numberOfGuests(), testBooking.numberOfNights(), 0); //carhire days is 0, only calculating base price

            //test
            Assert.AreEqual(expectedPrice, actualPrice, "Booking price is not correct, price calculation FAILED.");
        }