public void TestDeleteContainedEntities() { // Initialize entities TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(_participant, typeName); Assert.AreEqual(ReturnCode.Ok, result); Topic topic = _participant.CreateTopic(nameof(TestDeleteContainedEntities), typeName); Assert.IsNotNull(topic); Assert.IsNull(topic.GetListener()); Assert.AreEqual(nameof(TestDeleteContainedEntities), topic.Name); Assert.AreEqual(typeName, topic.TypeName); Publisher publisher = _participant.CreatePublisher(); Assert.IsNotNull(publisher); // Call DeleteContainedEntities in an empty publisher result = publisher.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, result); // Create a DataWriter in the publisher DataWriter dataWriter = publisher.CreateDataWriter(topic); Assert.IsNotNull(publisher); // Try to delete the publisher without delete the datawriter result = _participant.DeletePublisher(publisher); Assert.AreEqual(ReturnCode.PreconditionNotMet, result); // Call DeleteContainedEntities and remove the publisher again result = publisher.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, result); result = _participant.DeletePublisher(publisher); Assert.AreEqual(ReturnCode.Ok, result); }