diff options
Diffstat (limited to 'p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp')
-rw-r--r-- | p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp deleted file mode 100644 index 47d36c5..0000000 --- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#define BOOST_TEST_MODULE SqlSelectDeserializer -#include <boost/test/unit_test.hpp> -#include <slicer/db/sqlSelectDeserializer.h> -#include <slicer/slicer.h> -#include <connection.h> -#include <p2pvr.h> -#include <rdbmsDataSource.h> -#include <commonObjects.h> -#include <testOptionsSource.h> -#include <boost/filesystem/operations.hpp> -#include <definedDirs.h> -#include <commonHelpers.h> -#include "mockDefs.h" -#include <testAppInstance.h> - -typedef boost::shared_ptr<DB::SelectCommand> SelectPtr; - -class TestCommonObjects : public CommonObjects, public TestAppInstance { - public: - TestCommonObjects() - { - TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (rootDir / "datasources").string() }, - }); - } -}; - -BOOST_GLOBAL_FIXTURE( StandardMockDatabase ); - -BOOST_FIXTURE_TEST_SUITE ( Sql, TestCommonObjects ); - -BOOST_AUTO_TEST_CASE( listOfEvents ) -{ - auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); - auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 100")); - auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Events>(*sel); - BOOST_REQUIRE_EQUAL(res.size(), 100); - BOOST_REQUIRE_EQUAL(res[0]->ServiceId, 4166); - BOOST_REQUIRE_EQUAL(res[0]->EventId, 49741); - BOOST_REQUIRE_EQUAL(res[0]->Title, "Skiing Weatherview"); - BOOST_REQUIRE(!res[0]->Subtitle); - BOOST_REQUIRE_EQUAL(res[0]->Description, "Detailed weather forecast."); - BOOST_REQUIRE_EQUAL(res[0]->StartTime, Common::DateTime({2014, 12, 19, 0, 25})); - BOOST_REQUIRE_EQUAL(res[0]->StopTime, Common::DateTime({2014, 12, 19, 0, 30})); - BOOST_REQUIRE(res[0]->Current); - BOOST_REQUIRE_EQUAL(res[99]->ServiceId, 4166); - BOOST_REQUIRE_EQUAL(res[99]->EventId, 52448); - BOOST_REQUIRE_EQUAL(res[99]->Title, "East Midlands Today"); -} - -BOOST_AUTO_TEST_CASE( singleField ) -{ - auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); - auto sel = SelectPtr(db->newSelectCommand("SELECT EventId FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, int>(*sel); - BOOST_REQUIRE_EQUAL(res, 49741); -} - -BOOST_AUTO_TEST_CASE( singleEvent ) -{ - auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); - auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::EventPtr>(*sel); - BOOST_REQUIRE_EQUAL(res->ServiceId, 4166); - BOOST_REQUIRE_EQUAL(res->EventId, 49741); - BOOST_REQUIRE_EQUAL(res->Title, "Skiing Weatherview"); - BOOST_REQUIRE(!res->Subtitle); - BOOST_REQUIRE_EQUAL(res->Description, "Detailed weather forecast."); - BOOST_REQUIRE_EQUAL(res->StartTime, Common::DateTime({2014, 12, 19, 0, 25})); - BOOST_REQUIRE_EQUAL(res->StopTime, Common::DateTime({2014, 12, 19, 0, 30})); -} - -BOOST_AUTO_TEST_CASE( dynamicTypes ) -{ - auto db = dataSource<RdbmsDataSource>("postgres")->getReadonly(); - auto sel = SelectPtr(db->newSelectCommand("SELECT d.*, '::DVBSI::TerrestrialDelivery' \"typeid\" FROM delivery_dvbt d ORDER BY TransportStreamId")); - auto res = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, P2PVR::Deliveries>(*sel, "typeid"); - BOOST_REQUIRE_EQUAL(res.size(), 6); - auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(res[0]); - BOOST_REQUIRE_EQUAL(dvbt->Frequency, 682000000); - BOOST_REQUIRE_EQUAL(dvbt->TransportStreamId, 4170); - BOOST_REQUIRE_EQUAL(dvbt->CodeRateHP, 2); -} - -BOOST_AUTO_TEST_SUITE_END(); - |