Пример #1
0
        public void HasProperty()
        {
            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("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);

            // check for the properties
            Assert.Equal(true, testIntf.HasProperty("prop1"));
            Assert.Equal(true, testIntf.HasProperty("prop2"));
            Assert.Equal(true, testIntf.HasProperty("prop3"));
            Assert.Equal(false, testIntf.HasProperty("invalid_prop"));

            bus.Dispose();
        }
Пример #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);
        }
Пример #3
0
        public void AddProperty()
        {
            // 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);
        }
Пример #4
0
        public void HasProperties()
        {
            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);

            /*
             * At this point this is an empty interface the call to hasproperties should
             * return false.
             */
            Assert.False(testIntf.HasProperties);
            status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            /*
             * At this point the interface only contains a method call the call to
             * hasproperties should return false.
             */
            Assert.False(testIntf.HasProperties);
            status = testIntf.AddProperty("prop1", "s", AllJoyn.InterfaceDescription.AccessFlags.Read);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            /*
             * At this point the interface only contains a property the call to
             * hasproperties should return true.
             */
            Assert.True(testIntf.HasProperties);
            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);

            /*
             * At this point the interface only contains multiple properties the call to
             * hasproperties should return true.
             */
            Assert.True(testIntf.HasProperties);

            bus.Dispose();
        }
Пример #5
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();
        }
Пример #6
0
        public void GetProperties()
        {
            // create the interface
            AllJoyn.InterfaceDescription testIntf = null;
            Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface(INTERFACE_NAME, out testIntf));
            Assert.NotNull(testIntf);

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

            AllJoyn.InterfaceDescription.Property[] properties = testIntf.GetProperties();
            Assert.Equal(3, properties.Length);

            // This assumes that the properties are returned in alphabetic order
            // nothing states that the properties must be returned this way.
            Assert.Equal("prop1", properties[0].Name);
            Assert.Equal("prop2", properties[1].Name);
            Assert.Equal("prop3", properties[2].Name);
        }