Go to the documentation of this file.00001
00005
00006
00007
00008
00009 #include <sstream>
00010 #include <fstream>
00011 #include <string>
00012
00013 #define BOOST_TEST_DYN_LINK
00014 #define BOOST_TEST_MAIN
00015 #define BOOST_TEST_MODULE InventoryTestSuite
00016 #include <boost/test/unit_test.hpp>
00017
00018 #include <stdair/basic/BasLogParams.hpp>
00019 #include <stdair/basic/BasDBParams.hpp>
00020 #include <stdair/basic/BasFileMgr.hpp>
00021 #include <stdair/bom/TravelSolutionStruct.hpp>
00022 #include <stdair/bom/BookingRequestStruct.hpp>
00023 #include <stdair/service/Logger.hpp>
00024
00025 #include <airsched/AIRSCHED_Service.hpp>
00026 #include <airsched/config/airsched-paths.hpp>
00027
00028 namespace boost_utf = boost::unit_test;
00029
00030
00031 std::ofstream utfReportStream ("AirlineScheduleTestSuite_utfresults.xml");
00032
00036 struct UnitTestConfig {
00038 UnitTestConfig() {
00039 boost_utf::unit_test_log.set_stream (utfReportStream);
00040 boost_utf::unit_test_log.set_format (boost_utf::XML);
00041 boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
00042
00043 }
00044
00046 ~UnitTestConfig() {
00047 }
00048 };
00049
00050
00051
00052
00053
00054 BOOST_GLOBAL_FIXTURE (UnitTestConfig);
00055
00056
00057 BOOST_AUTO_TEST_SUITE (master_test_suite)
00058
00059
00062 BOOST_AUTO_TEST_CASE (airsched_simple_inventory_sell) {
00063
00064
00065 const stdair::Filename_T lScheduleInputFilename (STDAIR_SAMPLE_DIR
00066 "/schedule03.csv");
00067
00068
00069 const stdair::Filename_T lLogFilename ("AirlineScheduleTestSuite.log");
00070
00071
00072 bool doesExistAndIsReadable =
00073 stdair::BasFileMgr::doesExistAndIsReadable (lScheduleInputFilename);
00074 BOOST_CHECK_MESSAGE (doesExistAndIsReadable == true,
00075 "The '" << lScheduleInputFilename
00076 << "' input file can not be open and read");
00077
00078
00079 std::ofstream logOutputFile;
00080
00081 logOutputFile.open (lLogFilename.c_str());
00082 logOutputFile.clear();
00083
00084
00085 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
00086 AIRSCHED::AIRSCHED_Service airschedService (lLogParams);
00087
00088
00089 airschedService.parseAndLoad (lScheduleInputFilename);
00090
00091
00092
00093 const stdair::AirportCode_T lOrigin ("NCE");
00094 const stdair::AirportCode_T lDestination ("BKK");
00095 const stdair::AirportCode_T lPOS ("NCE");
00096 const stdair::Date_T lPreferredDepartureDate(2007, boost::gregorian::Apr, 21);
00097 const stdair::Date_T lRequestDate (2007, boost::gregorian::Mar, 21);
00098 const stdair::Duration_T lRequestTime (boost::posix_time::hours(8));
00099 const stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
00100 const stdair::CabinCode_T lPreferredCabin ("Bus");
00101 const stdair::PartySize_T lPartySize (3);
00102 const stdair::ChannelLabel_T lChannel ("DF");
00103 const stdair::TripType_T lTripType ("RO");
00104 const stdair::DayDuration_T lStayDuration (5);
00105 const stdair::FrequentFlyer_T lFrequentFlyerType ("NONE");
00106 const stdair::Duration_T lPreferredDepartureTime (boost::posix_time::hours(10));
00107 const stdair::WTP_T lWTP (2000.0);
00108 const stdair::PriceValue_T lValueOfTime (20.0);
00109 const stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination,
00110 lPOS,
00111 lPreferredDepartureDate,
00112 lRequestDateTime,
00113 lPreferredCabin,
00114 lPartySize, lChannel,
00115 lTripType, lStayDuration,
00116 lFrequentFlyerType,
00117 lPreferredDepartureTime,
00118 lWTP, lValueOfTime);
00119
00120
00121 stdair::TravelSolutionList_T lTravelSolutionList;
00122 airschedService.buildSegmentPathList (lTravelSolutionList, lBookingRequest);
00123 const unsigned int lNbOfTravelSolutions = lTravelSolutionList.size();
00124
00125
00126 const unsigned int lExpectedNbOfTravelSolutions = 4;
00127
00128
00129 STDAIR_LOG_DEBUG ("Number of travel solutions for the booking request '"
00130 << lBookingRequest.describe() << "': "
00131 << lNbOfTravelSolutions << ". It is expected to be "
00132 << lExpectedNbOfTravelSolutions << ".");
00133
00134 BOOST_CHECK_EQUAL (lNbOfTravelSolutions, lExpectedNbOfTravelSolutions);
00135
00136 BOOST_CHECK_MESSAGE(lNbOfTravelSolutions == lExpectedNbOfTravelSolutions,
00137 "The number of travel solutions for the booking request '"
00138 << lBookingRequest.describe() << "' is equal to "
00139 << lNbOfTravelSolutions << ", but it should be equal to "
00140 << lExpectedNbOfTravelSolutions);
00141
00142
00143 logOutputFile.close();
00144 }
00145
00146
00147 BOOST_AUTO_TEST_SUITE_END()
00148
00149