summaryrefslogtreecommitdiffstats
blob: d3e247fe20da348f776b8846a12a4b50ea24e250 (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
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include "Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h"

using namespace Swift;

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

	public:
		DiscoInfoSerializerTest() {}

		void testSerialize() {
			DiscoInfoSerializer testling;
			boost::shared_ptr<DiscoInfo> discoInfo(new DiscoInfo());
			discoInfo->addIdentity(DiscoInfo::Identity("Swift", "client", "pc"));
			discoInfo->addIdentity(DiscoInfo::Identity("Vlug", "client", "pc", "nl"));
			discoInfo->addFeature("http://jabber.org/protocol/caps");
			discoInfo->addFeature("http://jabber.org/protocol/disco#info");
			discoInfo->setNode("http://swift.im#bla");

			String expectedResult = 
				"<query node=\"http://swift.im#bla\" xmlns=\"http://jabber.org/protocol/disco#info\">"
					"<identity category=\"client\" name=\"Swift\" type=\"pc\"/>"
					"<identity category=\"client\" name=\"Vlug\" type=\"pc\" xml:lang=\"nl\"/>"
					"<feature var=\"http://jabber.org/protocol/caps\"/>"
					"<feature var=\"http://jabber.org/protocol/disco#info\"/>"
				"</query>";

			CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(discoInfo));
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoSerializerTest);