diff options
Diffstat (limited to 'p2pvr/daemon/unittests/testSi.cpp')
-rw-r--r-- | p2pvr/daemon/unittests/testSi.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp new file mode 100644 index 0000000..d191b38 --- /dev/null +++ b/p2pvr/daemon/unittests/testSi.cpp @@ -0,0 +1,105 @@ +#define BOOST_TEST_MODULE SI +#include <boost/test/unit_test.hpp> +#include <boost/filesystem/operations.hpp> +#include <testOptionsSource.h> +#include <Ice/ObjectAdapter.h> +#include <Ice/Service.h> +#include <maintenance.h> +#include <mockTuner.h> +#include <si.h> +#include <linux/dvb/frontend.h> +#include <definedDirs.h> +#include <boost/uuid/uuid_generators.hpp> +#include <boost/uuid/uuid_io.hpp> +#include <boost/lexical_cast.hpp> + +class Core { + public: + Core() + { + int paramCount = 0; + ic = Ice::initialize(paramCount, NULL); + auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12002"); + TestOptionsSource::LoadTestOptions({ + { "common.datasourceRoot", (RootDir / "datasources").string() }, + }); + adapter->add(new SI(), ic->stringToIdentity("SI")); + adapter->activate(); + + si = P2PVR::SIPrx::checkedCast(ic->stringToProxy("SI")); + BOOST_REQUIRE(si); + si->ice_ping(); + } + + ~Core() + { + ic->destroy(); + } + + P2PVR::SIPrx si; + + private: + Ice::CommunicatorPtr ic; +}; + +BOOST_FIXTURE_TEST_SUITE( SiCore, Core ) + +BOOST_AUTO_TEST_CASE ( si_getEvents ) +{ + // Get an event known to exist so we can use its uid + auto event = si->GetEvent(23968, 4378); + BOOST_REQUIRE(event); + + auto events = si->GetEvents({ event->EventUid }); + BOOST_REQUIRE_EQUAL(events.size(), 1); + BOOST_REQUIRE_EQUAL(events.front()->ServiceId, 23968); + BOOST_REQUIRE_EQUAL(events.front()->EventId, 4378); +} + +BOOST_AUTO_TEST_CASE ( si_getEvents_missing ) +{ + BOOST_REQUIRE_THROW(si->GetEvents({ 0 }), P2PVR::NotFound); +} + +BOOST_AUTO_TEST_CASE( si_getEvent ) +{ + auto event = si->GetEvent(23968, 4378); + BOOST_REQUIRE(event); + BOOST_REQUIRE_EQUAL(event->Title, "Timothy Goes to School"); + BOOST_REQUIRE_EQUAL(event->Current, true); +} + +BOOST_AUTO_TEST_CASE( si_getEventsOnNow ) +{ + si->EventsOnNow(); +} + +BOOST_AUTO_TEST_CASE( si_getEventsInSched ) +{ + si->EventsInSchedule(0); +} + +BOOST_AUTO_TEST_CASE( si_getEventsInScheds ) +{ + si->EventsInSchedules(); +} + +BOOST_AUTO_TEST_CASE( si_getEventsInRange ) +{ + si->EventsInRange(Common::DateTime {2014, 12, 19, 3, 0}, Common::DateTime {2014, 12, 20, 3, 0}); +} + +BOOST_AUTO_TEST_CASE( si_getEventSearch ) +{ + si->EventSearch("Top Gear", IceUtil::Optional< ::Ice::Int >(), + IceUtil::Optional<Common::DateTime>(), IceUtil::Optional<Common::DateTime>()); + si->EventSearch("Top Gear", 22272, + IceUtil::Optional<Common::DateTime>(), IceUtil::Optional<Common::DateTime>()); + si->EventSearch("Top Gear", 22272, + Common::DateTime {2014, 12, 19, 3, 0}, IceUtil::Optional<Common::DateTime>()); + si->EventSearch("Top Gear", 22272, + Common::DateTime {2014, 12, 19, 3, 0}, Common::DateTime {2014, 12, 20, 3, 0}); +} + +BOOST_AUTO_TEST_SUITE_END() + |