summaryrefslogtreecommitdiffstats
blob: a14214b0e246c8c00937668cb4853e1fffe501ce (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
/*
 * Copyright (c) 2011 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

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

#include <boost/smart_ptr/make_shared.hpp>

#include <Swiften/Serializer/PayloadSerializers/MUCAdminPayloadSerializer.h>

using namespace Swift;

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

	public:
		MUCAdminPayloadSerializerTest() {}

		void testSerialize() {
			MUCAdminPayloadSerializer testling;
			boost::shared_ptr<MUCAdminPayload> admin = boost::make_shared<MUCAdminPayload>();
			MUCItem item;
			item.affiliation = MUCOccupant::Owner;
			item.role = MUCOccupant::Visitor;
			item.reason = "malice";
			item.actor = JID("kev@tester.lit");
			admin->addItem(item);

			CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"), testling.serialize(admin));
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(MUCAdminPayloadSerializerTest);