summaryrefslogtreecommitdiffstats
blob: a298d782cb2521161385974f7d0c81a768b75d5b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (c) 2017 Tarun Gupta
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#include <gtest/gtest.h>

#include <Swiften/Serializer/PayloadSerializers/MIXParticipantSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>

using namespace Swift;

TEST(MIXParticipantSerializerTest, testSerializeEmpty) {
    MIXParticipantSerializer testling;

    std::shared_ptr<MIXParticipant> participant(new MIXParticipant());

    std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\"/>";
    ASSERT_EQ(expectedResult, testling.serialize(participant));
}

TEST(MIXParticipantSerializerTest, testSerializeNick) {
    MIXParticipantSerializer testling;

    std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
    participant->setNick("thirdwitch");

    std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
                      "<nick>thirdwitch</nick>"
                  "</participant>";
    ASSERT_EQ(expectedResult, testling.serialize(participant));
}

TEST(MIXParticipantSerializerTest, testSerializeJID) {
    MIXParticipantSerializer testling;

    std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
    participant->setJID(JID("hecate@mix.shakespeare.example"));

    std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
                      "<jid>hecate@mix.shakespeare.example</jid>"
                  "</participant>";
    ASSERT_EQ(expectedResult, testling.serialize(participant));
}

TEST(MIXParticipantSerializerTest, testSerializeJIDAndNick) {
    MIXParticipantSerializer testling;

    std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
    participant->setNick("thirdwitch");
    participant->setJID(JID("hecate@mix.shakespeare.example"));

    std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
                      "<nick>thirdwitch</nick>"
                      "<jid>hecate@mix.shakespeare.example</jid>"
                  "</participant>";
    ASSERT_EQ(expectedResult, testling.serialize(participant));
}