Dispose() public méthode

public Dispose ( ) : void
Résultat void
		public void IntrospectRemoteObject()
		{
			AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
			Assert.NotNull(proxyBusObject);

			Assert.Equal(AllJoyn.QStatus.OK, proxyBusObject.IntrospectRemoteObject());

			AllJoyn.InterfaceDescription interfaceDescription = proxyBusObject.GetInterface("org.freedesktop.DBus.Introspectable");

			string expectedIntrospect = "<interface name=\"org.freedesktop.DBus.Introspectable\">\n" +
										"  <method name=\"Introspect\">\n" +
										"    <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" +
										"  </method>\n" +
										"</interface>\n";
			Assert.Equal(expectedIntrospect, interfaceDescription.Introspect());


			proxyBusObject.Dispose();
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
			busAttachment.Dispose();
		}
		public void TestListenerRegisteredUnregistered()
		{
			AllJoyn.BusAttachment bus = new AllJoyn.BusAttachment("BusListenerTest", true);
			AllJoyn.BusListener busListener = new TestBusListener(this);
			listenerRegistered = false;
			listenerUnregistered = false;
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

			// start the bus attachment
			status = bus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// connect to the bus
			status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

			bus.RegisterBusListener(busListener);
			Wait(MaxWaitTime);
			Assert.Equal(true, listenerRegistered);

			bus.UnregisterBusListener(busListener);
			Wait(MaxWaitTime);
			Assert.Equal(true, listenerUnregistered);

			// TODO: move these into a teardown method?
			busListener.Dispose();
			bus.Dispose();
		}
		public void TestObjectRegisteredUnregistered()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

			// create+start+connect bus attachment
			AllJoyn.BusAttachment bus = null;
			bus = new AllJoyn.BusAttachment("BusObjectTest", true);
			Assert.NotNull(bus);

			status = bus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// create the bus object
			TestBusObject testBusObject = new TestBusObject(bus, OBJECT_PATH, this);
			objectRegistered = false;
			objectUnregistered = false;

			// test registering the bus object
			status = bus.RegisterBusObject(testBusObject);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Wait(MaxWaitTime);
			Assert.Equal(true, objectRegistered);

			// test unregistering the bus object
			bus.UnregisterBusObject(testBusObject);
			Wait(MaxWaitTime);
			Assert.Equal(true, objectUnregistered);

			bus.Dispose();

		}
		public void CreateDispose()
		{
			AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("MessageTest", false);
			AllJoyn.Message message = new AllJoyn.Message(busAttachment);

			message.Dispose();
			busAttachment.Dispose();
		}
		public void Concurrency()
		{
			AllJoyn.BusAttachment bus = null;
			bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
			// The default value for concurrency is 4
			Assert.Equal<uint>(4, bus.Concurrency);
			bus.Dispose();

			bus = new AllJoyn.BusAttachment("BusAttachmentTest", true, 8);
			Assert.Equal<uint>(8, bus.Concurrency);
			bus.Dispose();
		}
		public void CreateDispose()
		{
			AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("ProxyBusObjectTest", false);
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(busAttachment, "org.alljoyn.Bus", "/org/alljoyn/Bus", 0);
			Assert.NotNull(proxyBusObject);
			proxyBusObject.Dispose();
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Stop());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Join());
			busAttachment.Dispose();
		}
		public void CreateInterface()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;
			AllJoyn.BusAttachment bus = null;
			bus = new AllJoyn.BusAttachment("BusAttachmentTest", true);
			Assert.NotNull(bus);

			AllJoyn.InterfaceDescription testIntf = null;
			status = bus.CreateInterface("org.alljoyn.test.BusAttachment", out testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(testIntf);

			// TODO: move these into a teardown method?
			bus.Dispose();
		}
		public void Connect_no_params()
		{
			AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("BusAttachmentTest", true);
			Assert.NotNull(busAttachment);

			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Start());
			Assert.Equal(AllJoyn.QStatus.OK, busAttachment.Connect());

			Assert.True(busAttachment.IsConnected);

			Assert.True(busAttachment.ConnectSpec.Equals(AllJoynTestCommon.GetConnectSpec()) || busAttachment.ConnectSpec.Equals("null:"));

			busAttachment.Stop();
			busAttachment.Join();

			busAttachment.Dispose();
		}
		public void AddMember()
		{
			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);

			// Test adding a MethodCall
			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Test adding a Signal
			status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			bus.Dispose();
		}
		public void SignalAnnotations()
		{
			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);
			// Test adding a Signal
			status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

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

			// activate the interface
			testIntf.Activate();

			string value = "";
			testIntf.GetMemberAnnotation("chirp", "org.alljoyn.test.annotation.one", ref value);
			Assert.Equal("here", value);

			AllJoyn.InterfaceDescription.Member signal = testIntf.GetMember("chirp");

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

			Dictionary<string, string> annotations = signal.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();
		}
		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();
		}
		public void AddSignal()
		{
			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.AddSignal("signal1", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Verify the signal
			AllJoyn.InterfaceDescription.Member signalMember = null;
			signalMember = testIntf.GetMember("signal1");
			Assert.NotNull(signalMember);

			Assert.Equal(testIntf, signalMember.Iface);
			Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
			Assert.Equal("signal1", signalMember.Name);
			Assert.Equal("s", signalMember.Signature);
			Assert.Equal("", signalMember.ReturnSignature);
			Assert.Equal("data", signalMember.ArgNames);
			//TODO add in code to use new annotation methods

			bus.Dispose();
		}
		public void GetSignal()
		{
			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);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("foo", "", "", ""));
			status = testIntf.AddSignal("chirp", "s", "data", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Verify the signal
			AllJoyn.InterfaceDescription.Member signalMember = null;
			signalMember = testIntf.GetSignal("chirp");
			Assert.NotNull(signalMember);

			Assert.Equal(testIntf, signalMember.Iface);
			Assert.Equal(AllJoyn.Message.Type.Signal, signalMember.MemberType);
			Assert.Equal("chirp", signalMember.Name);
			Assert.Equal("s", signalMember.Signature);
			Assert.Equal("", signalMember.ReturnSignature);
			Assert.Equal("data", signalMember.ArgNames);

			AllJoyn.InterfaceDescription.Member methodMember = null;
			methodMember = testIntf.GetSignal("foo");
			//since "foo" is a method GetSignal should return null
			Assert.Null(methodMember);

			methodMember = testIntf.GetSignal("bar");
			// "bar" is not a member of the interface it should return null
			Assert.Null(methodMember);

			bus.Dispose();
		}
		public void GetName()
		{
			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);

			Assert.Equal(INTERFACE_NAME, testIntf.Name);

			bus.Dispose();
		}
		public void GetMember()
		{
			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);

			// Test adding a MethodCall
			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Test adding a Signal
			status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Verify the ping member
			AllJoyn.InterfaceDescription.Member pingMember = null;
			pingMember = testIntf.GetMember("ping");
			Assert.NotNull(pingMember);

			Assert.Equal(testIntf, pingMember.Iface);
			Assert.Equal(AllJoyn.Message.Type.MethodCall, pingMember.MemberType);
			Assert.Equal("ping", pingMember.Name);
			Assert.Equal("s", pingMember.Signature);
			Assert.Equal("s", pingMember.ReturnSignature);
			Assert.Equal("in,out", pingMember.ArgNames);
			//TODO add in code to use new annotation methods
			//Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, pingMember.Annotation);

			// Verify the chirp member
			AllJoyn.InterfaceDescription.Member chirpMember = null;
			chirpMember = testIntf.GetMember("chirp");
			Assert.NotNull(chirpMember);

			Assert.Equal(testIntf, chirpMember.Iface);
			Assert.Equal(AllJoyn.Message.Type.Signal, chirpMember.MemberType);
			Assert.Equal("chirp", chirpMember.Name);
			Assert.Equal("", chirpMember.Signature);
			Assert.Equal("s", chirpMember.ReturnSignature);
			Assert.Equal("chirp", chirpMember.ArgNames);
			//TODO add in code to use new annotation methods
			//Assert.Equal(AllJoyn.InterfaceDescription.AnnotationFlags.Default, chirpMember.Annotation);

			bus.Dispose();
		}
		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();
		}
		public void HasMember()
		{
			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);

			// Test adding a MethodCall
			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Test adding a Signal
			status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			Assert.Equal(true, testIntf.HasMember("ping", "s", "s"));
			Assert.Equal(true, testIntf.HasMember("chirp", "", "s"));

			/*
			 * expected to be false even though the members exist the signatures do not
			 * match what is expected.
			 */
			Assert.Equal(false, testIntf.HasMember("ping", "i", "s"));
			Assert.Equal(false, testIntf.HasMember("chirp", "b", null));
			Assert.Equal(false, testIntf.HasMember("invalid", "s", null));

			bus.Dispose();
		}
		public void AddMethod()
		{
			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;
			Assert.Equal(AllJoyn.QStatus.OK, bus.CreateInterface(INTERFACE_NAME, out testIntf));
			Assert.NotNull(testIntf);

			// Test adding a MethodCall
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));

			// Test adding a Signal
			status = testIntf.AddMethod("pong", "", "s", "pong-in", AllJoyn.InterfaceDescription.AnnotationFlags.Deprecated | AllJoyn.InterfaceDescription.AnnotationFlags.NoReply);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			string expectedIntrospect = "<interface name=\"org.alljoyn.test.InterfaceDescriptionTest\">\n" +
										"  <method name=\"ping\">\n" +
										"    <arg name=\"in\" type=\"s\" direction=\"in\"/>\n" +
										"    <arg name=\"out\" type=\"s\" direction=\"out\"/>\n" +
										"  </method>\n" +
										"  <method name=\"pong\">\n" +
										"    <arg name=\"pong-in\" type=\"s\" direction=\"out\"/>\n" +
										"    <annotation name=\"org.freedesktop.DBus.Deprecated\" value=\"true\"/>\n" +
										"    <annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>\n" +
										"  </method>\n" +
										"</interface>\n";
			Assert.Equal(expectedIntrospect, testIntf.Introspect());

			bus.Dispose();
		}
		public void TestAddMethodHandler()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

			// create+start+connect bus attachment
			AllJoyn.BusAttachment servicebus = null;
			servicebus = new AllJoyn.BusAttachment("BusObjectTestService", true);
			Assert.NotNull(servicebus);

			status = servicebus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			status = servicebus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

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

			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out");
			Assert.Equal(AllJoyn.QStatus.OK, status);

			testIntf.Activate();

			// register bus listener
			AllJoyn.BusListener testBusListener = new TestBusListener(this);
			servicebus.RegisterBusListener(testBusListener);

			// create the bus object
			// the MethodTestBusObject constructor adds the interface & a handler for the ping method
			MethodTestBusObject methodTestBusObject = new MethodTestBusObject(servicebus, OBJECT_PATH);

			// register the bus object
			status = servicebus.RegisterBusObject(methodTestBusObject);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// request name
			nameOwnerChangedFlag = false;
			status = servicebus.RequestName(OBJECT_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Wait(MaxWaitTime);
			Assert.Equal(true, nameOwnerChangedFlag);

			///////////////////////////////////////////////////////////

			// create the proxy bus object & call methods
			AllJoyn.BusAttachment bus = null;
			bus = new AllJoyn.BusAttachment("BusObjectTest", true);
			Assert.NotNull(bus);

			status = bus.Start();
			Assert.Equal(AllJoyn.QStatus.OK, status);

			status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
			Assert.Equal(AllJoyn.QStatus.OK, status);

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

			status = iFace.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out");
			Assert.Equal(AllJoyn.QStatus.OK, status);

			iFace.Activate();

			AllJoyn.ProxyBusObject proxyBusObject = new AllJoyn.ProxyBusObject(bus, OBJECT_NAME, OBJECT_PATH, 0);
			status = proxyBusObject.AddInterface(iFace);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			AllJoyn.MsgArg input = new AllJoyn.MsgArg();
			input.Set("AllJoyn");
			AllJoyn.Message replyMsg = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCall(INTERFACE_NAME, "ping", input, replyMsg, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg[0]);

//continue testing obsolete method calls till they are removed.
#pragma warning disable 618
			AllJoyn.MsgArg input1 = new AllJoyn.MsgArg();
			input1.Set("AllJoyn");
			AllJoyn.Message replyMsg1 = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ping", input1, replyMsg1, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg1[0]);

			AllJoyn.MsgArgs input2 = new AllJoyn.MsgArgs(1);
			input2[0].Set("AllJoyn");
			AllJoyn.Message replyMsg2 = new AllJoyn.Message(bus);
			status = proxyBusObject.MethodCallSynch(INTERFACE_NAME, "ping", input2, replyMsg2, 5000, 0);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.Equal("AllJoyn", (string)replyMsg2[0]);
#pragma warning restore 618

			methodTestBusObject.Dispose();
			servicebus.Dispose();

			// TODO: need to call dispose on proxyBusObject first otherwise you get an AccessViolation???
			proxyBusObject.Dispose();
			bus.Dispose();
		}
		public void GetArgs()
		{
			//SetUp Service
			//start service BusAttachment
			AllJoyn.BusAttachment serviceBus = new AllJoyn.BusAttachment("MessageTestService", true);
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

			TestBusListener testBusListener = new TestBusListener(this);
			serviceBus.RegisterBusListener(testBusListener);

			//Create and activate the service Interface
			AllJoyn.InterfaceDescription testIntf = null;
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, out testIntf));
			Assert.NotNull(testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out"));
			testIntf.Activate();

			//create and register BusObject
			MessageTestBusObject busObj = new MessageTestBusObject(OBJECT_PATH);
			busObj.AddInterface(testIntf);
			AllJoyn.InterfaceDescription.Member ping;
			ping = testIntf.GetMember("ping");
			Assert.NotNull(ping);

			Assert.Equal(AllJoyn.QStatus.OK, busObj.AddMethodHandler(ping, busObj.Ping));

			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RegisterBusObject(busObj));

			_nameOwnerChangedFlag = false;
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting |
																					AllJoyn.DBus.NameFlags.DoNotQueue |
																					AllJoyn.DBus.NameFlags.AllowReplacement));
			Wait(TimeSpan.FromSeconds(2));
			Assert.True(_nameOwnerChangedFlag);


			//SetUp Client
			//start client BusAttachment
			AllJoyn.BusAttachment clientBus = new AllJoyn.BusAttachment("MessageTestClient", true);
			Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.ProxyBusObject proxyObj = new AllJoyn.ProxyBusObject(clientBus, WELLKNOWN_NAME, OBJECT_PATH, 0);

			Assert.Equal(AllJoyn.QStatus.OK, proxyObj.IntrospectRemoteObject());

			AllJoyn.Message reply = new AllJoyn.Message(clientBus);
			AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn");

			proxyObj.MethodCall(INTERFACE_NAME, "ping", input, reply, 25000, 0);

			//Actual tests for GetArg/GetArgs
			// call using GetArg specifying the array index
			Assert.Equal("AllJoyn", (string)reply.GetArg(0));
			// use the this[] operator call to get the MsgArg
			Assert.Equal("AllJoyn", (string)(reply[0]));
			// Return the MsgArgs note could be multiple values
			AllJoyn.MsgArg replyArg = reply.GetArgs();
			Assert.Equal(1, replyArg.Length);
			Assert.Equal("AllJoyn", (string)replyArg);
			// Parse the Message Drectly
			object replyString;
			Assert.Equal(AllJoyn.QStatus.OK, reply.GetArgs("s", out replyString));
			Assert.Equal("AllJoyn", (string)replyString);

			serviceBus.UnregisterBusListener(testBusListener);
			reply.Dispose();
			input.Dispose();
			proxyObj.Dispose();
			clientBus.Dispose();

			testBusListener.Dispose();
			busObj.Dispose();
			serviceBus.Dispose();
		}
		public void IsSecure()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

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

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

			Assert.Equal(false, testIntf.IsSecure);

			bus.DeleteInterface(testIntf);

			// create a secure interface
			status = bus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Inherit, out testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(testIntf);

			Assert.Equal(false, testIntf.IsSecure);
			Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Inherit, testIntf.GetSecurityPolicy);
			bus.DeleteInterface(testIntf);

			// create a secure interface
			status = bus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Off, out testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(testIntf);

			Assert.Equal(false, testIntf.IsSecure);
			Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Off, testIntf.GetSecurityPolicy);

			bus.DeleteInterface(testIntf);

			// create a secure interface
			status = bus.CreateInterface(INTERFACE_NAME, AllJoyn.InterfaceDescription.SecurityPolicy.Required, out testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(testIntf);

			Assert.Equal(true, testIntf.IsSecure);
			Assert.Equal(AllJoyn.InterfaceDescription.SecurityPolicy.Required, testIntf.GetSecurityPolicy);

			bus.Dispose();
		}
		public void Activate()
		{
			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);

			// Test adding a MethodCall
			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// Test adding a Signal
			status = testIntf.AddMember(AllJoyn.Message.Type.Signal, "chirp", "", "s", "chirp", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.OK, status);

			// activate the interface
			testIntf.Activate();

			/* once the interface has been activated we should not be able to add new members */
			status = testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "pong", "s", "s", "in,out", AllJoyn.InterfaceDescription.AnnotationFlags.Default);
			Assert.Equal(AllJoyn.QStatus.BUS_INTERFACE_ACTIVATED, status);

			bus.Dispose();
		}
		public void InterfaceDescriptionEquals()
		{
			AllJoyn.BusAttachment servicebus = null;
			servicebus = new AllJoyn.BusAttachment("InterfaceDescriptionTest", true);
			Assert.NotNull(servicebus);

			// create the interface one
			AllJoyn.InterfaceDescription testIntf = null;
			Assert.Equal(AllJoyn.QStatus.OK, servicebus.CreateInterface(INTERFACE_NAME, out testIntf));
			Assert.NotNull(testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("chirp", "s", "chirp"));
			testIntf.Activate();

			Assert.Equal(AllJoyn.QStatus.OK, servicebus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, servicebus.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.BusObject busObject = new AllJoyn.BusObject(OBJECT_PATH, false);
			Assert.Equal(AllJoyn.QStatus.OK, busObject.AddInterface(testIntf));

			Assert.Equal(AllJoyn.QStatus.OK, servicebus.RegisterBusObject(busObject));

			Assert.Equal(AllJoyn.QStatus.OK, servicebus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.AllowReplacement |
				AllJoyn.DBus.NameFlags.DoNotQueue | AllJoyn.DBus.NameFlags.ReplaceExisting));

			AllJoyn.BusAttachment clientbus = null;
			clientbus = new AllJoyn.BusAttachment("InterfaceDescriptionTestclient", true);
			Assert.NotNull(clientbus);

			Assert.Equal(AllJoyn.QStatus.OK, clientbus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, clientbus.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.ProxyBusObject proxy = new AllJoyn.ProxyBusObject(clientbus, WELLKNOWN_NAME, OBJECT_PATH, 0);
			Assert.Equal(AllJoyn.QStatus.OK, proxy.IntrospectRemoteObject());

			AllJoyn.InterfaceDescription testIntf2 = proxy.GetInterface(INTERFACE_NAME);
			Assert.NotNull(testIntf);

			// create the interface three
			AllJoyn.InterfaceDescription testIntf3 = null;
			Assert.Equal(AllJoyn.QStatus.OK, servicebus.CreateInterface(INTERFACE_NAME + ".three", out testIntf3));
			Assert.NotNull(testIntf3);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddMethod("ping", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddMethod("pong", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf3.AddSignal("chirp", "s", "chirp"));

			Assert.True(testIntf == testIntf2);
			Assert.True(testIntf.Equals(testIntf2));
			Assert.True(testIntf.GetHashCode() == testIntf2.GetHashCode());

			Assert.False(testIntf == testIntf3);
			Assert.False(testIntf.Equals(testIntf3));
			Assert.False(testIntf.GetHashCode() == testIntf3.GetHashCode());

			proxy.Dispose();
			busObject.Dispose();

			servicebus.Stop();
			servicebus.Join();

			clientbus.Stop();
			clientbus.Join();

			servicebus.Dispose();
			clientbus.Dispose();
		}
		public void GetProperty()
		{
			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);

			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);

			bus.Dispose();
		}
Exemple #25
0
        public static void Main(string[] args)
        {
            Console.WriteLine("AllJoyn Library version: " + AllJoyn.GetVersion());
            Console.WriteLine("AllJoyn Library buildInfo: " + AllJoyn.GetBuildInfo());

            // Enable callbacks on main thread only
            AllJoyn.SetMainThreadOnlyCallbacks(true);

            // Create message bus
            sMsgBus = new AllJoyn.BusAttachment("myApp", true);

            // Add org.alljoyn.Bus.method_sample interface
            AllJoyn.InterfaceDescription testIntf;
            AllJoyn.QStatus status = sMsgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            if(status)
            {
                Console.WriteLine("Interface Created.");
                testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr");
                testIntf.Activate();
            }
            else
            {
                Console.WriteLine("Failed to create interface 'org.alljoyn.Bus.method_sample'");
            }

            // Create a bus listener
            sBusListener = new MyBusListener();
            if(status)
            {
                sMsgBus.RegisterBusListener(sBusListener);
                Console.WriteLine("BusListener Registered.");
            }

            // Set up bus object
            TestBusObject testObj = new TestBusObject(sMsgBus, SERVICE_PATH);

            // Start the msg bus
            if(status)
            {
                status = sMsgBus.Start();
                if(status)
                {
                    Console.WriteLine("BusAttachment started.");
                    sMsgBus.RegisterBusObject(testObj);

                    status = sMsgBus.Connect(connectArgs);
                    if(status)
                    {
                        Console.WriteLine("BusAttchement connected to " + connectArgs);
                    }
                    else
                    {
                        Console.WriteLine("BusAttachment::Connect(" + connectArgs + ") failed.");
                    }
                }
                else
                {
                    Console.WriteLine("BusAttachment.Start failed.");
                }
            }

            // Request name
            if(status)
            {
                status = sMsgBus.RequestName(SERVICE_NAME,
                    AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if(!status)
                {
                    Console.WriteLine("RequestName({0}) failed (status={1})", SERVICE_NAME, status);
                }
            }

            // Create session
            AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                    AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if(status)
            {
                ushort sessionPort = SERVICE_PORT;
                sSessionPortListener = new MySessionPortListener();
                status = sMsgBus.BindSessionPort(ref sessionPort, opts, sSessionPortListener);
                if(!status)
                {
                    Console.WriteLine("BindSessionPort failed ({0})", status);
                }
            }

            // Advertise name
            if(status)
            {
                status = sMsgBus.AdvertiseName(SERVICE_NAME, opts.Transports);
                if(!status)
                {
                    Console.WriteLine("Failed to advertise name {0} ({1})", SERVICE_NAME, status);
                }
            }

            if(status)
            {
                while(true)
                {
                    AllJoyn.TriggerCallbacks(); // Pump messages
                    System.Threading.Thread.Sleep(1);
                }
            }

            // Dispose of objects now
            sMsgBus.Dispose();
            sBusListener.Dispose();

            Console.WriteLine("basic server exiting with status {0} ({1})", status, status.ToString());
        }
		public void GetMethod()
		{
			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);

			// Test adding a MethodCall
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMethod("ping", "s", "s", "in,out"));
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddSignal("foo", "", ""));

			// Verify the ping member
			AllJoyn.InterfaceDescription.Member pingMember = null;
			pingMember = testIntf.GetMethod("ping");
			Assert.NotNull(pingMember);

			Assert.Equal(testIntf, pingMember.Iface);
			Assert.Equal(AllJoyn.Message.Type.MethodCall, pingMember.MemberType);
			Assert.Equal("ping", pingMember.Name);
			Assert.Equal("s", pingMember.Signature);
			Assert.Equal("s", pingMember.ReturnSignature);
			Assert.Equal("in,out", pingMember.ArgNames);

			AllJoyn.InterfaceDescription.Member fooMember = null;
			fooMember = testIntf.GetMethod("foo");
			// since "foo" is a signal is should return null when using GetMethod
			Assert.Null(fooMember);

			fooMember = testIntf.GetMethod("bar");
			// since "bar" is not a member of the interface it should be null
			Assert.Null(fooMember);

			bus.Dispose();
		}
		public void Properties()
		{
			//SetUp Service
			//start service BusAttachment
			AllJoyn.BusAttachment serviceBus = new AllJoyn.BusAttachment("MessageTestService", true);
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.Connect(AllJoynTestCommon.GetConnectSpec()));

			TestBusListener testBusListener = new TestBusListener(this);
			serviceBus.RegisterBusListener(testBusListener);

			//Create and activate the service Interface
			AllJoyn.InterfaceDescription testIntf = null;
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.CreateInterface(INTERFACE_NAME, out testIntf));
			Assert.NotNull(testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "ping", "s", "s", "in,out"));
			testIntf.Activate();

			//create and register BusObject
			MessageTestBusObject busObj = new MessageTestBusObject(OBJECT_PATH);
			busObj.AddInterface(testIntf);
			AllJoyn.InterfaceDescription.Member ping;
			ping = testIntf.GetMember("ping");
			Assert.NotNull(ping);

			Assert.Equal(AllJoyn.QStatus.OK, busObj.AddMethodHandler(ping, busObj.Ping));

			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RegisterBusObject(busObj));

			_nameOwnerChangedFlag = false;
			Assert.Equal(AllJoyn.QStatus.OK, serviceBus.RequestName(WELLKNOWN_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting |
																					AllJoyn.DBus.NameFlags.DoNotQueue |
																					AllJoyn.DBus.NameFlags.AllowReplacement));
			Wait(TimeSpan.FromSeconds(2));

			Assert.True(_nameOwnerChangedFlag);


			// SetUp Client
			// start client BusAttachment
			AllJoyn.BusAttachment clientBus = new AllJoyn.BusAttachment("MessageTestClient", true);
			Assert.Equal(AllJoyn.QStatus.OK, clientBus.Start());
			Assert.Equal(AllJoyn.QStatus.OK, clientBus.Connect(AllJoynTestCommon.GetConnectSpec()));

			AllJoyn.ProxyBusObject proxyObj = new AllJoyn.ProxyBusObject(clientBus, INTERFACE_NAME, OBJECT_PATH, 0);

			Assert.Equal(AllJoyn.QStatus.OK, proxyObj.IntrospectRemoteObject());

			AllJoyn.Message reply = new AllJoyn.Message(clientBus);
			AllJoyn.MsgArg input = new AllJoyn.MsgArg("s", "AllJoyn");

			proxyObj.MethodCall(INTERFACE_NAME, "ping", input, reply, 25000, 0);

			// Actual tests for GetArg/GetArgs
			// check the message properties
			Assert.False(reply.IsBroadcastSignal);
			Assert.False(reply.IsGlobalBroadcast);
			Assert.False(reply.IsSessionless);
			Assert.False(reply.IsExpired());
			uint timeLeft;
			reply.IsExpired(out timeLeft);
			Assert.True(timeLeft > 0);
			Assert.False(reply.IsUnreliable);
			Assert.False(reply.IsEncrypted);
			// we don't expect any flags
			Assert.Equal((byte)0, reply.Flags);
			// no security is being used so there should be no security mechanism
			Assert.Equal("", reply.AuthMechanism);
			Assert.Equal(AllJoyn.Message.Type.MethodReturn, reply.MessageType);
			// The serial is unknown before hand but it should not be zero
			Assert.NotEqual<uint>(0u, reply.CallSerial);
			Assert.NotEqual<uint>(0u, reply.ReplySerial);
			// A method return does not have an Object Path
			Assert.Equal("", reply.ObjectPath);
			// A method return does not have an interface specified
			Assert.Equal("", reply.Interface);
			// The member name is not specified on a message return
			Assert.Equal("", reply.MemberName);
			// TODO possible error the documentation for Sender states it should
			// be returning the well-known name however in this case it is
			// returning the unique name of the sender.
			Assert.Equal(serviceBus.UniqueName, reply.Sender);
			Assert.Equal(clientBus.UniqueName, reply.ReceiveEndPointName);
			Assert.Equal(clientBus.UniqueName, reply.Destination);
			Assert.Equal(0u, reply.CompressionToken);
			// no session set up for this test Session Id should be 0
			Assert.Equal(0u, reply.SessionId);
			String errorMsg;
			// TODO produce test that generates actual error Message
			Assert.Null(reply.GetErrorName(out errorMsg));
			Assert.Equal("", errorMsg);
			// The  ToString method only returns a string when running debug code
#if DEBUG
			Assert.True(reply.ToString().StartsWith("<message endianness="));
			Assert.True(reply.ToString().Contains("<header field=\"REPLY_SERIAL\">"));
			Assert.True(reply.ToString().Contains("<header field=\"DESTINATION\">"));
			Assert.True(reply.ToString().Contains("<header field=\"SENDER\">"));
			Assert.True(reply.ToString().Contains("<header field=\"SIGNATURE\">"));
			Assert.True(reply.ToString().Contains("<signature>s</signature>"));
			Assert.True(reply.ToString().Contains("<string>AllJoyn</string>"));
			Assert.True(reply.ToString().EndsWith("</message>"));

			// this call to description should return 'METHID_RET[<reply serial>](s)'
			Assert.True(reply.Description.StartsWith("METHOD_RET["));
#else
			Assert.Equal("", reply.ToString());
			Assert.Equal("", reply.Description);
#endif
			// TODO figure out a good way to test the TimeStamp property
			//reply.TimeStamp

			// CleanUp
			serviceBus.UnregisterBusListener(testBusListener);
			reply.Dispose();
			input.Dispose();
			proxyObj.Dispose();
			clientBus.Dispose();

			testBusListener.Dispose();
			busObj.Dispose();
			serviceBus.Dispose();
		}
		public void IsSecure_DepricatedCreateInterface()
		{
			AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

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

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

			Assert.Equal(false, testIntf.IsSecure);

			bus.DeleteInterface(testIntf);

			// create a secure interface
			status = bus.CreateInterface(INTERFACE_NAME, true, out testIntf);
			Assert.Equal(AllJoyn.QStatus.OK, status);
			Assert.NotNull(testIntf);

			Assert.Equal(true, testIntf.IsSecure);

			bus.Dispose();
		}
		public void SetCredentials()
		{
			AllJoyn.BusAttachment busAttachment = new AllJoyn.BusAttachment("PasswordManagerTest", false);
			Assert.Equal(AllJoyn.QStatus.OK, AllJoyn.PasswordManager.SetCredentials("ALLJOYN_PIN_KEYX", "1234"));
			busAttachment.Dispose();
		}
		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();
		}