Beispiel #1
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!");
        }
Beispiel #2
0
        public void RemoveExtra_Method_Removes_Guest_If_Guest_Does_Exist()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();

            //Add Extras to booking list
            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);

            int index = 1;

            aBooking.RemoveExtra(index); // Should remove the Extra at index 1
            Assert.AreEqual(aBooking.Extras.Count, 1, "Extra was removed successfuly");
        }
Beispiel #3
0
        // Returns a null extra if extra cannot be found in the list
        public void GetExtra_Method_Returns_Null_If_Extra_Does_Not_Exist()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();

            //Add Extras to booking list
            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);

            int   index  = 2;
            Extra extra3 = aBooking.GetExtra(index); //Should return a null Extra

            Assert.AreEqual(extra3, null, "Guest can not be found! (null)");
        }
Beispiel #4
0
        // Should return the right extra given its index
        public void GetExtra_Method_Returns_The_Right_Extra_If_It_Does_Exist_In_The_List()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();
            Extra Extra3 = new Breakfast();

            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);
            aBooking.AddExtra(Extra3);

            CarHire carhire1 = (CarHire)Extra2;
            int     index    = 1;
            CarHire carhire2 = (CarHire)aBooking.GetExtra(index); //Should return Extra2

            Assert.AreEqual(carhire1.DriverName, carhire2.DriverName, "Method returns the right extra");
        }
Beispiel #5
0
        // Should add an extra successfuly given an extra object
        public void AddExtra_Method_Works_Correctly()
        {
            Booking aBooking = new Booking();
            //Create Guest
            Extra Extra1 = new Breakfast();

            aBooking.AddExtra(Extra1); //Should add the extra to the list of extras correctly
            Assert.AreEqual(aBooking.Extras.Count, 1, "Guest was removed successfuly");
        }
Beispiel #6
0
        // Throws exception if extra with the provided index does not exist
        public void RemoveExtra_Method_Throws_Exception_If_Extra_Does_Not_Exist()
        {
            Booking aBooking = new Booking();
            //Create extra
            Extra extra1 = new Breakfast();

            //Add extra to booking list
            aBooking.AddExtra(extra1);

            int index = 2;

            aBooking.RemoveExtra(index); // Should throw exception since extra at index 2 does not exist
        }