예제 #1
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.");
        }
예제 #2
0
        private void btn_extra_breakfast_Click(object sender, RoutedEventArgs e)
        {//Add breakfast prices
            //get booking
            Booking selectedBooking = Bookings.getBooking(getSelectedKey_BookingRef());

            selectedBooking.Breakfast = true; //store the extra

            //create new breakfast
            Breakfast_add breakfast = new Breakfast_add();

            breakfast.AddTo(selectedBooking);
            //calculate new price
            calculateTotalPrice(selectedBooking, breakfast);
            //display cost
            lbl_breakfast_cost.Content   += breakfast.getCost();
            lbl_breakfast_cost.Visibility = Visibility.Visible;
            //switch the buttons
            refreshExtrasButtons();
        }