diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
3 files changed, 44 insertions, 5 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp new file mode 100644 index 0000000..23ff4a0 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp @@ -0,0 +1,21 @@ +#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h" + +#include <cppunit/extensions/HelperMacros.h> + +#include "Swiften/Serializer/PayloadSerializer.h" + +namespace Swift { + +String PayloadsSerializer::serialize(boost::shared_ptr<Payload> payload) { + PayloadSerializer* serializer = serializers.getPayloadSerializer(payload); + if (serializer) { + return serializer->serialize(payload); + } + else { + CPPUNIT_ASSERT(false); + return ""; + } +} + + +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h new file mode 100644 index 0000000..9fca334 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h @@ -0,0 +1,17 @@ +#pragma once + +#include <boost/shared_ptr.hpp> + +#include "Swiften/Elements/Payload.h" +#include "Swiften/Base/String.h" +#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" + +namespace Swift { + class PayloadsSerializer { + public: + String serialize(boost::shared_ptr<Payload> payload); + + private: + FullPayloadSerializerCollection serializers; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp index 158e7f1..daf43c5 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp @@ -1,7 +1,8 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> -#include "Swiften/Serializer/PayloadSerializers/StorageSerializer.h" +#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h" +#include "Swiften/Elements/Storage.h" using namespace Swift; @@ -15,7 +16,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { StorageSerializerTest() {} void testSerialize() { - StorageSerializer testling; + PayloadsSerializer serializer; boost::shared_ptr<Storage> storage(new Storage()); Storage::Conference conference; conference.name = "Council of Oberon"; @@ -34,11 +35,11 @@ class StorageSerializerTest : public CppUnit::TestFixture { "<nick>Puck</nick>" "<password>MyPass</password>" "</conference>" - "</storage>"), testling.serialize(storage)); + "</storage>"), serializer.serialize(storage)); } void testSerialize_NoNickOrPassword() { - StorageSerializer testling; + PayloadsSerializer serializer; boost::shared_ptr<Storage> storage(new Storage()); Storage::Conference conference; conference.name = "Council of Oberon"; @@ -52,7 +53,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { "autojoin=\"1\" " "jid=\"council@conference.underhill.org\" " "name=\"Council of Oberon\"/>" - "</storage>"), testling.serialize(storage)); + "</storage>"), serializer.serialize(storage)); } }; |