Beispiel #1
0
        public void MsgArgToString()
        {
            AllJoyn.MsgArg arg = new AllJoyn.MsgArg();
            arg = "Asign a string";
            #if DEBUG
            Assert.Equal("<string>Asign a string</string>", arg.ToString());
            Assert.Equal("  <string>Asign a string</string>", arg.ToString(2));
            #else
            Assert.Equal("", arg.ToString());
            Assert.Equal("", arg.ToString(2));
            #endif

            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;
            object[][] sii = new object[][]
                            {
                                new object[] {1, 2},
                                new object[] {11, 22},
                                new object[] {111, 222}
                            };

            //signature a(ii);
            AllJoyn.MsgArg structs = new AllJoyn.MsgArg(3);
            status = structs[0].Set("(ii)", sii[0]);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = structs[1].Set("(ii)", sii[1]);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = structs[2].Set("(ii)", sii[2]);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            Assert.Equal("(ii)", structs[0].Signature);

            AllJoyn.MsgArg struct_array = new AllJoyn.MsgArg();
            status = struct_array.Set("a(ii)", structs);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            #if DEBUG
            string expected = "<array type_sig=\"(ii)\">\n" +
                            "  <struct>\n" +
                            "    <int32>1</int32>\n" +
                            "    <int32>2</int32>\n" +
                            "  </struct>\n" +
                            "  <struct>\n" +
                            "    <int32>11</int32>\n" +
                            "    <int32>22</int32>\n" +
                            "  </struct>\n" +
                            "  <struct>\n" +
                            "    <int32>111</int32>\n" +
                            "    <int32>222</int32>\n" +
                            "  </struct>\n" +
                            "</array>";
            Assert.Equal(expected, struct_array.ToString());
            #else
            Assert.Equal("", struct_array.ToString());
            #endif

            AllJoyn.MsgArg arg2 = new AllJoyn.MsgArg(2);
            arg2.Set("ii", new object[] { 42, 24 });
            #if DEBUG
            Assert.Equal("<int32>42</int32>\n<int32>24</int32>", arg2.ToString());
            #else
            Assert.Equal("", arg2.ToString());
            #endif
        }