public void TestSetListener() { // Create a new Publisher without listener Publisher publisher = _participant.CreatePublisher(); Assert.IsNotNull(publisher); MyPublisherListener listener = (MyPublisherListener)publisher.GetListener(); Assert.IsNull(listener); // Create a listener, set it and check that is correctly setted listener = new MyPublisherListener(); ReturnCode result = publisher.SetListener(listener, StatusMask.AllStatusMask); Assert.AreEqual(ReturnCode.Ok, result); MyPublisherListener received = (MyPublisherListener)publisher.GetListener(); Assert.IsNotNull(received); Assert.AreEqual(listener, received); // Remove the listener calling SetListener with null and check it result = publisher.SetListener(null, StatusMask.NoStatusMask); Assert.AreEqual(ReturnCode.Ok, result); received = (MyPublisherListener)publisher.GetListener(); Assert.IsNull(received); }
public void TestGetListener() { // Create a new Publisher with a listener MyPublisherListener listener = new MyPublisherListener(); Publisher publisher = _participant.CreatePublisher(listener); Assert.IsNotNull(publisher); // Call to GetListener and check the listener received MyPublisherListener received = (MyPublisherListener)publisher.GetListener(); Assert.IsNotNull(received); Assert.AreEqual(listener, received); }
public void TestGetListener() { // Create a new Publisher with a listener MyPublisherListener listener = new MyPublisherListener(); Publisher publisher = _participant.CreatePublisher(null, listener); Assert.IsNotNull(publisher); // Call to GetListener and check the listener received #pragma warning disable CS0618 // Type or member is obsolete MyPublisherListener received = (MyPublisherListener)publisher.GetListener(); #pragma warning restore CS0618 // Type or member is obsolete Assert.IsNotNull(received); Assert.AreEqual(listener, received); }
public void TestInitialize() { _participant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(_participant); _participant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(_participant, typeName); Assert.AreEqual(ReturnCode.Ok, result); _topic = _participant.CreateTopic(TestContext.TestName, typeName); Assert.IsNotNull(_topic); Assert.IsNull(_topic.Listener); Assert.AreEqual(TestContext.TestName, _topic.Name); Assert.AreEqual(typeName, _topic.TypeName); SubscriberQos sQos = new SubscriberQos(); sQos.EntityFactory.AutoenableCreatedEntities = false; sQos.Presentation.OrderedAccess = true; sQos.Presentation.CoherentAccess = true; sQos.Presentation.AccessScope = PresentationQosPolicyAccessScopeKind.InstancePresentationQos; _subscriber = _participant.CreateSubscriber(sQos); Assert.IsNotNull(_subscriber); _listener = new MyPublisherListener(); PublisherQos pQos = new PublisherQos(); pQos.EntityFactory.AutoenableCreatedEntities = false; pQos.Presentation.OrderedAccess = true; pQos.Presentation.CoherentAccess = true; pQos.Presentation.AccessScope = PresentationQosPolicyAccessScopeKind.InstancePresentationQos; _publisher = _participant.CreatePublisher(pQos, _listener); Assert.IsNotNull(_publisher); _writer = _publisher.CreateDataWriter(_topic); Assert.IsNotNull(_writer); _dataWriter = new TestStructDataWriter(_writer); DataReaderQos qos = new DataReaderQos(); qos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; _reader = _subscriber.CreateDataReader(_topic, qos); Assert.IsNotNull(_reader); }