Exemplo n.º 1
0
        public void PropertyAnnotations()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
            Assert.NotNull(bus);

            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", "here");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.two", "lies");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.three", "some");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.four", "amazing");
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddPropertyAnnotation("prop", "org.alljoyn.test.annotation.five", "treasure");
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // activate the interface
            testIntf.Activate();

            AllJoyn.InterfaceDescription.Property property = testIntf.GetProperty("prop");
            Assert.Equal("prop", property.Name);
            Assert.Equal("s", property.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Read, property.Access);

            string value = "";

            Assert.True(testIntf.GetPropertyAnnotation("prop", "org.alljoyn.test.annotation.one", ref value));
            Assert.Equal("here", value);

            Assert.True(property.GetAnnotation("org.alljoyn.test.annotation.two", ref value));
            Assert.Equal("lies", value);

            Dictionary <string, string> annotations = property.GetAnnotations();

            Assert.Equal(5, annotations.Count);

            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.one", out value));
            Assert.Equal("here", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.two", out value));
            Assert.Equal("lies", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.three", out value));
            Assert.Equal("some", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.four", out value));
            Assert.Equal("amazing", value);
            Assert.True(annotations.TryGetValue("org.alljoyn.test.annotation.five", out value));
            Assert.Equal("treasure", value);
            bus.Dispose();
        }
Exemplo n.º 2
0
        public void GetProperty()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            status = bus.CreateInterface(INTERFACE_NAME, out testIntf);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            Assert.NotNull(testIntf);

            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop2", "i", AllJoyn.InterfaceDescription.AccessFlags.Write);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            status = testIntf.AddProperty("prop3", "u", AllJoyn.InterfaceDescription.AccessFlags.ReadWrite);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            AllJoyn.InterfaceDescription.Property prop1 = testIntf.GetProperty("prop1");
            Assert.Equal("prop1", prop1.Name);
            Assert.Equal("s", prop1.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Read, prop1.Access);

            AllJoyn.InterfaceDescription.Property prop2 = testIntf.GetProperty("prop2");
            Assert.Equal("prop2", prop2.Name);
            Assert.Equal("i", prop2.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.Write, prop2.Access);

            AllJoyn.InterfaceDescription.Property prop3 = testIntf.GetProperty("prop3");
            Assert.Equal("prop3", prop3.Name);
            Assert.Equal("u", prop3.Signature);
            Assert.Equal(AllJoyn.InterfaceDescription.AccessFlags.ReadWrite, prop3.Access);
        }