Exemplo n.º 1
0
        public void RegisterSubscriber_Success()
        {
            var result = new object[3]
            {
                1,
                "Subscribed to [/topic1]",
                new object[0]
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginRegisterSubscriberStringStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6, t7) => { t6(null); return null; };
            MMasterProxy.AllInstances.EndRegisterSubscriberIAsyncResult = (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            client.RegisterSubscriberAsync("/test", "topic1", "std_msgs/String", new Uri("http://192.168.11.2:11112")).Wait();
        }
Exemplo n.º 2
0
        public void RegisterSubscriber_ParameterError()
        {
            var result = new object[3]
            {
                -1,
                "ERROR: parameter [topic_type] is not a valid package resource name",
                0
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MMasterProxy.AllInstances.BeginRegisterSubscriberStringStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6, t7) => { t6(null); return null; };
            MMasterProxy.AllInstances.EndRegisterSubscriberIAsyncResult= (t1, t2) => result;

            var client = new MasterClient(new Uri("http://localhost"));

            var ex = AssertEx.Throws<AggregateException>(() => client.RegisterSubscriberAsync("/test", "topic1", "topicType", new Uri("http://192.168.11.2:11112")).Wait());
            ex.InnerException.Message.Is("ERROR: parameter [topic_type] is not a valid package resource name");
        }