summaryrefslogtreecommitdiffstats
blob: 266b0661d42d54f9093b5d0598cdbf6872994dc4 (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
60
61
/*
 * 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/MIXPayloadSerializer.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>

using namespace Swift;

TEST(MIXPayloadSerializerTest, testSerializeEmpty) {
    MIXPayloadSerializer testling;

    auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());

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

TEST(MIXPayloadSerializerTest, testSerializeNick) {
    MIXPayloadSerializer testling;

    auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
    mix->setNick("thirdwitch");

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

TEST(MIXPayloadSerializerTest, testSerializeJID) {
    MIXPayloadSerializer testling;

    auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
    mix->setJID(JID("hecate@mix.shakespeare.example"));

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

TEST(MIXPayloadSerializerTest, testSerializeAll) {
    MIXPayloadSerializer testling;

    auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
    mix->setNick("thirdwitch");
    mix->setJID(JID("hecate@mix.shakespeare.example"));
    mix->setSubmissionID("92vax143g");

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