summaryrefslogtreecommitdiffstats
blob: 5aeb9ddf5479d03d0f66a71c0c856a4dc9f17795 (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-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <memory>

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

#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;
            std::shared_ptr<MUCAdminPayload> admin = std::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);