13 #define BOOST_TEST_DYN_LINK
14 #define BOOST_TEST_MAIN
15 #define BOOST_TEST_MODULE InventoryTestSuite
16 #include <boost/test/unit_test.hpp>
18 #include <stdair/basic/BasLogParams.hpp>
19 #include <stdair/basic/BasDBParams.hpp>
20 #include <stdair/basic/BasFileMgr.hpp>
21 #include <stdair/bom/TravelSolutionStruct.hpp>
22 #include <stdair/bom/BookingRequestStruct.hpp>
23 #include <stdair/service/Logger.hpp>
28 namespace boost_utf = boost::unit_test;
31 std::ofstream utfReportStream (
"AirlineScheduleTestSuite_utfresults.xml");
36 struct UnitTestConfig {
39 boost_utf::unit_test_log.set_stream (utfReportStream);
40 boost_utf::unit_test_log.set_format (boost_utf::XML);
41 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
54 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
57 BOOST_AUTO_TEST_SUITE (master_test_suite)
62 BOOST_AUTO_TEST_CASE (airsched_simple_inventory_sell) {
65 const stdair::Filename_T lScheduleInputFilename (STDAIR_SAMPLE_DIR
69 const stdair::Filename_T lLogFilename (
"AirlineScheduleTestSuite.log");
72 bool doesExistAndIsReadable =
73 stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
74 BOOST_CHECK_MESSAGE (doesExistAndIsReadable ==
true,
75 "The '" << lScheduleInputFilename
76 <<
"' input file can not be open and read");
79 std::ofstream logOutputFile;
81 logOutputFile.open (lLogFilename.c_str());
82 logOutputFile.clear();
85 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
89 airschedService.parseAndLoad (lScheduleInputFilename);
93 const stdair::AirportCode_T lOrigin (
"NCE");
94 const stdair::AirportCode_T lDestination (
"BKK");
95 const stdair::AirportCode_T lPOS (
"NCE");
96 const stdair::Date_T lPreferredDepartureDate(2007, boost::gregorian::Apr, 21);
97 const stdair::Date_T lRequestDate (2007, boost::gregorian::Mar, 21);
98 const stdair::Duration_T lRequestTime (boost::posix_time::hours(8));
99 const stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
100 const stdair::CabinCode_T lPreferredCabin (
"Bus");
101 const stdair::PartySize_T lPartySize (3);
102 const stdair::ChannelLabel_T lChannel (
"DF");
103 const stdair::TripType_T lTripType (
"RO");
104 const stdair::DayDuration_T lStayDuration (5);
105 const stdair::FrequentFlyer_T lFrequentFlyerType (
"NONE");
106 const stdair::Duration_T lPreferredDepartureTime (boost::posix_time::hours(10));
107 const stdair::WTP_T lWTP (2000.0);
108 const stdair::PriceValue_T lValueOfTime (20.0);
109 const stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination,
111 lPreferredDepartureDate,
114 lPartySize, lChannel,
115 lTripType, lStayDuration,
117 lPreferredDepartureTime,
121 stdair::TravelSolutionList_T lTravelSolutionList;
122 airschedService.buildSegmentPathList (lTravelSolutionList, lBookingRequest);
123 const unsigned int lNbOfTravelSolutions = lTravelSolutionList.size();
126 const unsigned int lExpectedNbOfTravelSolutions = 4;
129 STDAIR_LOG_DEBUG (
"Number of travel solutions for the booking request '"
130 << lBookingRequest.describe() <<
"': "
131 << lNbOfTravelSolutions <<
". It is expected to be "
132 << lExpectedNbOfTravelSolutions <<
".");
134 BOOST_CHECK_EQUAL (lNbOfTravelSolutions, lExpectedNbOfTravelSolutions);
136 BOOST_CHECK_MESSAGE(lNbOfTravelSolutions == lExpectedNbOfTravelSolutions,
137 "The number of travel solutions for the booking request '"
138 << lBookingRequest.describe() <<
"' is equal to "
139 << lNbOfTravelSolutions <<
", but it should be equal to "
140 << lExpectedNbOfTravelSolutions);
143 logOutputFile.close();
147 BOOST_AUTO_TEST_SUITE_END()