public void SendTaskAsync_Success() { var str = new std_msgs.String(); var header = new { callerid = "test", topic = "mytopic", md5sum = str.Md5Sum, type = str.MessageType }; var stream = new MemoryStream(); TcpRosHeaderSerializer.Serialize(stream, header); MTcpRosClient.AllInstances.ReceiveAsyncInt32 = (t1, t2) => Observable.Return(stream.ToArray()); MTcpRosClient.AllInstances.SendAsyncByteArray = (t1, t2) => Task.Factory.StartNew(() => t2.Length); var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var topic = new RosTopicClient <std_msgs.String>("mynode", "mytopic"); topic.StartAsync(sock).Wait(); topic.SendAsync(new std_msgs.String() { data = "test" }).Result.Is(12); }
public void SendTaskAsync_NotConnectedError() { var topic = new RosTopicClient <std_msgs.String>("mynode", "mytopic"); var ex = AssertEx.Throws <InvalidOperationException>(() => topic.SendAsync(new std_msgs.String() { data = "test" }).Wait()); ex.Message.Is("Not Connected"); }