summaryrefslogtreecommitdiffstats
blob: b174d32683df9a90be2d2d3286a295cfad6af56a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2014 Kevin Smith and Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include <boost/smart_ptr/make_shared.hpp>

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include <Swiften/Base/DateTime.h>
#include <Swiften/Serializer/PayloadSerializers/MAMArchivedSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>

using namespace Swift;

class MAMArchivedSerializerTest : public CppUnit::TestFixture {
		CPPUNIT_TEST_SUITE(MAMArchivedSerializerTest);
		CPPUNIT_TEST(testSerialize);
		CPPUNIT_TEST_SUITE_END();

	public:
		void testSerialize() {
			MAMArchivedSerializer serializer(&serializers);

			boost::shared_ptr<MAMArchived> archived(boost::make_shared<MAMArchived>());
			archived->setBy("juliet@capulet.lit");
			archived->setID("28482-98726-73623");

			std::string expectedResult =
				"<archived by=\"juliet@capulet.lit\" id=\"28482-98726-73623\" xmlns=\"urn:xmpp:mam:0\"/>";

			CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(archived));
		}

	private:
		FullPayloadSerializerCollection serializers;
};

CPPUNIT_TEST_SUITE_REGISTRATION(MAMArchivedSerializerTest);