*/
#include <sstream>
#include <fstream>
#include <string>
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE FQTTestSuite
#include <boost/test/unit_test.hpp>
#include <stdair/basic/BasLogParams.hpp>
#include <stdair/basic/BasDBParams.hpp>
#include <stdair/basic/BasFileMgr.hpp>
#include <stdair/service/Logger.hpp>
#include <stdair/bom/TravelSolutionStruct.hpp>
#include <stdair/bom/BookingRequestStruct.hpp>
#include <simfqt/config/simfqt-paths.hpp>
namespace boost_utf = boost::unit_test;
struct UnitTestConfig {
UnitTestConfig() {
static std::ofstream _test_log ("FQTTestSuite_utfresults.xml");
boost_utf::unit_test_log.set_stream (_test_log);
boost_utf::unit_test_log.set_format (boost_utf::XML);
boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);
}
~UnitTestConfig() {
}
};
void testFareQuoterHelper (const unsigned short iTestFlag,
const stdair::Filename_T iFareInputFilename,
const bool isBuiltin) {
std::ostringstream oStr;
oStr << "FQTTestSuite_" << iTestFlag << ".log";
const stdair::Filename_T lLogFilename (oStr.str());
std::ofstream logOutputFile;
logOutputFile.open (lLogFilename.c_str());
logOutputFile.clear();
const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
logOutputFile);
if (isBuiltin == true) {
simfqtService.buildSampleBom();
} else {
simfqtService.parseAndLoad (lFareFilePath);
}
stdair::TravelSolutionList_T lTravelSolutionList;
simfqtService.buildSampleTravelSolutions (lTravelSolutionList);
stdair::BookingRequestStruct lBookingRequest =
simfqtService.buildBookingRequest();
simfqtService.quotePrices (lBookingRequest, lTravelSolutionList);
logOutputFile.close();
}
BOOST_GLOBAL_FIXTURE (UnitTestConfig);
BOOST_AUTO_TEST_SUITE (master_test_suite)
BOOST_AUTO_TEST_CASE (simfqt_simple_pricing_test) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fare01.csv");
const bool isBuiltin = false;
BOOST_CHECK_NO_THROW (testFareQuoterHelper (0, lFareInputFilename, isBuiltin));
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_01) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError01.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (1, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_02) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError02.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (2, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_03) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError03.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (3, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_04) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError04.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (4, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_05) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError05.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (5, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_06) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError06.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (6, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_07) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/fareError07.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (7, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_08) {
const stdair::Filename_T lFareInputFilename (STDAIR_SAMPLE_DIR "/missingFile.csv");
const bool isBuiltin = false;
BOOST_CHECK_THROW (testFareQuoterHelper (8, lFareInputFilename, isBuiltin),
}
BOOST_AUTO_TEST_CASE (simfqt_error_pricing_test_09) {
const stdair::Filename_T lEmptyInputFilename (STDAIR_SAMPLE_DIR "/ ");
const bool isBuiltin = true;
BOOST_CHECK_NO_THROW(testFareQuoterHelper (9, lEmptyInputFilename, isBuiltin));
}
BOOST_AUTO_TEST_SUITE_END()