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

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

#include <Swiften/Parser/PayloadParsers/MUCAdminPayloadParser.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>

using namespace Swift;

class MUCAdminPayloadParserTest : public CppUnit::TestFixture
{
        CPPUNIT_TEST_SUITE(MUCAdminPayloadParserTest);
        CPPUNIT_TEST(testParse);
        CPPUNIT_TEST_SUITE_END();

    public:
        MUCAdminPayloadParserTest() {}

        void testParse() {
            PayloadsParserTester parser;

            CPPUNIT_ASSERT(parser.parse("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"));

            MUCAdminPayload::ref payload = std::dynamic_pointer_cast<MUCAdminPayload>(parser.getPayload());
            MUCItem item = payload->getItems()[0];
            CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
            CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
            CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
            CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
        }
};

CPPUNIT_TEST_SUITE_REGISTRATION(MUCAdminPayloadParserTest);