public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "type is registered."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; mod.tstTypeSupport typesupport; DDS.ReturnCode returnCode; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } typesupport = new mod.tstTypeSupport(); if (typesupport == null) { result = new Test.Framework.TestResult(expResult, "TypeSupport is not constructed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = typesupport.RegisterType(participant, "mod::tst"); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "TypeSupport is not registered." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Setting/resolving default TopicQos succeeded."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.TopicQos tqosHolder = null; DDS.ReturnCode returnCode; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (participant.GetDefaultTopicQos(ref tqosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Topic qos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string sh; DDS.ErrorCode eh; DDS.ReturnCode ddsReturnCode; DDS.ErrorInfo errInfo = new DDS.ErrorInfo(); if (errInfo.Update() != DDS.ReturnCode.NoData) { return(new Test.Framework.TestResult("Update returns NO_DATA prior to error", "Update did not return NO_DATA prior to error" , expVerdict, Test.Framework.TestVerdict.Fail)); } sh = "<>"; ddsReturnCode = errInfo.GetLocation(out sh); if ((ddsReturnCode != DDS.ReturnCode.NoData))// || (!sh.Equals("<>"))) { return(new Test.Framework.TestResult("get_location returns NO_DATA and does not modify string" , "Different result and/or string modified", expVerdict, Test.Framework.TestVerdict.Fail)); } ddsReturnCode = errInfo.GetMessage(out sh); if ((ddsReturnCode != DDS.ReturnCode.NoData))// || (!sh.Equals("<>"))) { return(new Test.Framework.TestResult("get_message returns NO_DATA and does not modify string" , "Different result and/or string modified", expVerdict, Test.Framework.TestVerdict.Fail)); } ddsReturnCode = errInfo.GetStackTrace(out sh); if ((ddsReturnCode != DDS.ReturnCode.NoData))// || (!sh.Equals("<>"))) { return(new Test.Framework.TestResult("get_stack_trace returns NO_DATA and does not modify string" , "Different result and/or string modified", expVerdict, Test.Framework.TestVerdict.Fail)); } ddsReturnCode = errInfo.GetSourceLine(out sh); if ((ddsReturnCode != DDS.ReturnCode.NoData))// || (!sh.Equals("<>"))) { return(new Test.Framework.TestResult("get_source_line returns NO_DATA and does not modify string" , "Different result and/or string modified", expVerdict, Test.Framework.TestVerdict.Fail)); } eh = (DDS.ErrorCode)(-1); ddsReturnCode = errInfo.GetCode(out eh); if ((ddsReturnCode != DDS.ReturnCode.NoData) || (eh != DDS.ErrorCode.Undefined)) { return(new Test.Framework.TestResult("get_code returns NO_DATA and does not modify error code" , "Different result and/or error code modified", expVerdict, Test.Framework.TestVerdict.Fail)); } return(new Test.Framework.TestResult("sacs_errorinfo_tc1 successfull", "sacs_errorinfo_tc1_successfull" , expVerdict, Test.Framework.TestVerdict.Pass)); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Resolving DomainParticipantFactory succeeded."; DDS.DomainParticipantFactory factory; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
/// <summary>Execute the testcase</summary> public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "All instances of DomainParticipantFactory are the same"; DDS.DomainParticipantFactory[] factory = new DDS.DomainParticipantFactory[3]; result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); factory[0] = DDS.DomainParticipantFactory.Instance; factory[1] = DDS.DomainParticipantFactory.Instance; factory[2] = DDS.DomainParticipantFactory.Instance; if (factory[0] != factory[1] || factory[1] != factory[2]) { result = new Test.Framework.TestResult(expResult, "Not all instances are the same" , expVerdict, expVerdict); } return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "get_current_time test succeeded"; DDS.IDomainParticipant participant; DDS.ReturnCode returnCode; DDS.Time timeHolder; participant = (DDS.IDomainParticipant) this.ResolveObject("participant"); returnCode = participant.GetCurrentTime(out timeHolder); if (returnCode == DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, expResult, expVerdict, Test.Framework.TestVerdict.Pass); } else { result = new Test.Framework.TestResult(expResult, "get_current_time test failed." , expVerdict, Test.Framework.TestVerdict.Fail); } return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; int status; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "uninitialized struct TestUnionStarts can be written/received without errors."; DDS.IDomainParticipant participant; testDefConstr.TestUnionStartsTypeSupport tusTS; string tusTypeName; DDS.ITopic tusTopic; DDS.IPublisher pub; DDS.ISubscriber sub; DDS.IDataWriter dw; testDefConstr.TestUnionStartsDataWriter tusDW; DDS.IDataReader dr; testDefConstr.TestUnionStartsDataReader tusDR; long handle; string resultMsg; // Create Participant. participant = DDS.TheParticipantFactory.Value.CreateParticipant(DDS.DomainId.Default, DDS.PARTICIPANT_QOS_DEFAULT .Value, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Register TypeSupport. tusTS = new testDefConstr.TestUnionStartsTypeSupport(); tusTypeName = tusTS.TypeName; status = tusTS.RegisterType(participant, tusTypeName); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Registering of TestUnionStarts TypeSupport failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Topic. tusTopic = participant.CreateTopic("TestUnionStarts", tusTypeName, DDS.TOPIC_QOS_DEFAULT .Value, null, 0); if (tusTopic == null) { result = new Test.Framework.TestResult(expResult, "Creation of TestUnionStarts Topic failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Publisher. pub = participant.CreatePublisher(DDS.PUBLISHER_QOS_DEFAULT.Value, null, 0); if (pub == null) { result = new Test.Framework.TestResult(expResult, "Creation of Publisher failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create ADataWriter. dw = pub.CreateDataWriter(tusTopic, DDS.DATAWRITER_QOS_USE_TOPIC_QOS.Value, null , 0); tusDW = testDefConstr.TestUnionStartsDataWriterHelper.Narrow(dw); if (tusDW == null) { result = new Test.Framework.TestResult(expResult, "Creation of TestUnionStartsDataWriter failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Subscriber. sub = participant.CreateSubscriber(DDS.SUBSCRIBER_QOS_DEFAULT.Value, null, 0); if (pub == null) { result = new Test.Framework.TestResult(expResult, "Creation of Subscriber failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create ADataReader. dr = sub.CreateDataReader(tusTopic, DDS.DATAREADER_QOS_USE_TOPIC_QOS.Value, null , 0); tusDR = testDefConstr.TestUnionStartsDataReaderHelper.Narrow(dr); if (tusDR == null) { result = new Test.Framework.TestResult(expResult, "Creation of TestUnionStartsDataReader failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Instantiate a sample of A and test if it is initialized properly. testDefConstr.TestUnionStarts tus = new testDefConstr.TestUnionStarts(); resultMsg = TestInit(tus); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Default initialization of TestUnionStarts not successful: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Register the sample and write it into the system. handle = tusDW.Register_instance(tus); if (handle == 0) { result = new Test.Framework.TestResult(expResult, "Registering an instance of type TestUnionStarts failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = tusDW.Write(tus, handle); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Writing an instance of type TestUnionStarts failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Read the sample and check whether everything is initialized properly. testDefConstr.TestUnionStartsSeqHolder msgSeq = new testDefConstr.TestUnionStartsSeqHolder (); DDS.SampleInfo[] infoSeq = new DDS.SampleInfo[] (); status = tusDR.Take(msgSeq, infoSeq, DDS.Length.Unlimited, DDS.NOT_READ_SAMPLE_STATE .Value, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Alive); if (msgSeq.Value.Length != 1) { result = new Test.Framework.TestResult(expResult, "Wrong number of samples received." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } resultMsg = TestInit(msgSeq.Value[0]); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Received TestUnionStarts Sample has a different state from its orginial: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Delete all entities. status = participant.DeleteContainedEntities(); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deleting contained entities failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = DDS.TheParticipantFactory.Value.DeleteParticipant(participant); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deleting participant failed.", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Default participantQos is used when PARTICIPANT_QOS_DEFAULT is specified."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.DomainParticipantQos pqosHolder2 = null; DDS.ReturnCode returnCode; byte[] ud; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.GetDefaultParticipantQos(ref pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved (" + returnCode + ").", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } pqosHolder.EntityFactory.AutoenableCreatedEntities = true; ud = new byte[1]; ud[0] = System.Convert.ToByte("4"); pqosHolder.UserData.Value = ud; returnCode = factory.SetDefaultParticipantQos(pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Set default participant qos failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of participant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = participant.GetQos(ref pqosHolder2); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Resolving of ParticipantQos failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deleting participant failed.", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.EntityFactory.AutoenableCreatedEntities != pqosHolder2 .EntityFactory.AutoenableCreatedEntities) { result = new Test.Framework.TestResult(expResult, "Resolved entity_factory policy does not match the applied one." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.UserData.Value.Length != pqosHolder2.UserData.Value. Length) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.UserData.Value[0] != pqosHolder2.UserData.Value[0]) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one (2)." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Default publisherQos is used when PUBLISHER_QOS_DEFAULT is specified."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.PublisherQos pubQosHolder = null; DDS.PublisherQos pubQosHolder2 = null; DDS.IPublisher pub; DDS.ReturnCode returnCode; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Publisher qos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } string[] name = new string[2]; name[0] = "Publisher"; name[1] = "QoS"; pubQosHolder.Partition.Name = name; returnCode = participant.SetDefaultPublisherQos(pubQosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Setting default publisher QoS failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } pub = participant.CreatePublisher(); if (pub == null) { result = new Test.Framework.TestResult(expResult, "Publisher could not be created." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } pub.GetQos(ref pubQosHolder2); if (!pubQosHolder.Partition.Name[0].Equals(pubQosHolder.Partition.Name [0]) || !pubQosHolder.Partition.Name[1].Equals(pubQosHolder.Partition .Name[1])) { result = new Test.Framework.TestResult(expResult, "Default publisher QoS is not taken when PUBLISHER_QOS_DEFAULT is specified." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = participant.DeletePublisher(pub); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deletion of Publisher failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Creating/deleting DomainParticipant succeeded."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.IDomainParticipant participant2; DDS.DomainParticipantQos pqosHolder = null; DDS.ReturnCode returnCode; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.GetDefaultParticipantQos(ref pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved (" + returnCode + ").", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could not be created." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant2 = factory.CreateParticipant(string.Empty, pqosHolder);//, null, 0); if (participant2 == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipant 2 could not be created." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could not be deleted." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant2); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "DomainParticipant 2 could not be deleted." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant2 = factory.CreateParticipant(null, pqosHolder);//, null, 0); if (participant2 == null) { return(new Test.Framework.TestResult(expResult, "failure creating a DomainParticipant with an empty domainId" , expVerdict, Test.Framework.TestVerdict.Fail)); } returnCode = factory.DeleteParticipant(participant2); if (returnCode != DDS.ReturnCode.Ok) { return(new Test.Framework.TestResult(expResult, "erroneous returncode while deleting a participant" , expVerdict, Test.Framework.TestVerdict.Fail)); } participant = factory.LookupParticipant(string.Empty); if (participant != null) { return(new Test.Framework.TestResult(expResult, "could still lookup deleted participant" , expVerdict, Test.Framework.TestVerdict.Fail)); } returnCode = factory.DeleteParticipant(participant); if (returnCode == DDS.ReturnCode.Ok) { return(new Test.Framework.TestResult(expResult, "could delete a non existing participant" , expVerdict, Test.Framework.TestVerdict.Fail)); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "get_discovered_xxx succeeded."; DDS.DomainParticipantFactory dpf; DDS.IDomainParticipant dp1; DDS.IDomainParticipant dp2; DDS.IDomainParticipant dp3; DDS.ITopic topic1; DDS.ITopic topic2; DDS.TopicQos tQos; tc_get_discovered_xxx.Type1TypeSupport type1_ts; bool dp1res = false; bool dp2res = false; bool dp3res = false; bool t1res = false; bool t2res = false; DDS.ReturnCode returnCode; DDS.ParticipantBuiltinTopicData participant_data = null; DDS.TopicBuiltinTopicData topic_data = null; DDS.SampleInfo[] sample_infos = null; DDS.DomainParticipantQos dpQos = null; DDS.InstanceHandle[] sequence = null; DDS.InstanceHandle[] sequence1 = null; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); tQos = new DDS.TopicQos(); dpf = DDS.DomainParticipantFactory.Instance; if (dpf == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could be initialised." , expVerdict, Test.Framework.TestVerdict.Pass); if (dpf.GetDefaultParticipantQos(ref dpQos) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } dpQos.UserData.Value = encoding.GetBytes("dp1"); dp1 = dpf.CreateParticipant(DDS.DomainId.Default, dpQos, null, 0); if (dp1 == null) { result = new Test.Framework.TestResult(expResult, "Test case failed. Failed to create dp1 participant" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } dpQos.UserData.Value = encoding.GetBytes("dp2"); dp2 = dpf.CreateParticipant(DDS.DomainId.Default, dpQos, null, 0); if (dp2 == null) { result = new Test.Framework.TestResult(expResult, "Test case failed. Failed to create dp2 participant" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } dpQos.UserData.Value = encoding.GetBytes("dp3"); dp3 = dpf.CreateParticipant(DDS.DomainId.Default, dpQos, null, 0); if (dp3 == null) { result = new Test.Framework.TestResult(expResult, "Test case failed. Failed to create dp3 participant" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } /* * Get default Topic Qos settings */ dp1.GetDefaultTopicQos(ref tQos); /* Create Topic */ type1_ts = new tc_get_discovered_xxx.Type1TypeSupport(); type1_ts.RegisterType(dp1, "tc_get_discovered_xxx::Type1"); topic1 = dp1.CreateTopic("Topic1", "tc_get_discovered_xxx::Type1", tQos); if (topic1 == null) { result = new Test.Framework.TestResult(expResult, "Test case failed. Failed to create Topic1" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } topic2 = dp1.CreateTopic("Topic2", "tc_get_discovered_xxx::Type1", tQos); if (topic2 == null) { result = new Test.Framework.TestResult(expResult, "Test case failed. Failed to create Topic2" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = dp1.GetDiscoveredParticipants(ref sequence); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "get_discovered_participants returned not OK." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } else { /* the test should find 5 participants: * buildinParticipant * spliced * dp1 * dp2 * dp3 */ if (sequence.Length != 5) { result = new Test.Framework.TestResult(expResult, "get_discovered_participants failed found: " + sequence.Length + " expected 5" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } /* read from each handle the UserDataQos and check the result against the made participant names*/ for (int i = 0; i < sequence.Length; i++) { returnCode = dp1.GetDiscoveredParticipantData(ref participant_data, sequence[i]); if (returnCode == DDS.ReturnCode.Ok) { if (participant_data.UserData.Value.Length > 0) { if (encoding.GetString(participant_data.UserData.Value).CompareTo("dp1") == 0) { dp1res = true; } else if (encoding.GetString(participant_data.UserData.Value).CompareTo("dp2") == 0) { dp2res = true; } else if (encoding.GetString(participant_data.UserData.Value).CompareTo("dp3") == 0) { dp3res = true; } } // returnCode = dataReader.ReturnLoan(ref data_values, ref sample_infos); } else { result = new Test.Framework.TestResult( expResult, "read instance failed", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } } if (!dp1res || !dp2res || !dp3res) { result = new Test.Framework.TestResult( expResult, "failed to discover all participants", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } } returnCode = dp1.GetDiscoveredTopics(ref sequence1); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "get_discovered_topics returned not OK." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } else { if (sequence1.Length != 15) { result = new Test.Framework.TestResult(expResult, "get_discovered_topics failed found: " + sequence1.Length + " expected 15" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } /* read from each handle the name and check the result against the made topic names*/ for (int i = 0; i < sequence1.Length; i++) { returnCode = dp1.GetDiscoveredTopicData(ref topic_data, sequence1[i]); if (returnCode == DDS.ReturnCode.Ok) { if (topic_data.Name.CompareTo("Topic1") == 0) { t1res = true; } else if (topic_data.Name.CompareTo("Topic2") == 0) { t2res = true; } } else { result = new Test.Framework.TestResult( expResult, "get discovered topic data failed", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } } if (!t1res || !t2res) { result = new Test.Framework.TestResult( expResult, "failed to discover all topics", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict); return(result); } }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Resolving GuardCondition succeeded."; DDS.ICondition[] holder = null; DDS.ReturnCode[] resultCode = new DDS.ReturnCode[] { DDS.ReturnCode.Error, DDS.ReturnCode.Error, DDS.ReturnCode.Error }; DDS.ReturnCode ddsReturnCode; bool continueTesting = true; DDS.GuardCondition condition1 = (DDS.GuardCondition)ResolveObject("condition1"); DDS.GuardCondition condition2 = (DDS.GuardCondition)ResolveObject("condition2"); DDS.GuardCondition condition3 = (DDS.GuardCondition)ResolveObject("condition3"); DDS.WaitSet waitset = new DDS.WaitSet(); resultCode[0] = waitset.AttachCondition(condition1); resultCode[1] = waitset.AttachCondition(condition2); resultCode[2] = waitset.AttachCondition(condition3); if (resultCode[0] != 0 || resultCode[1] != 0 || resultCode[2] != 0) { result = new Test.Framework.TestResult("attached guardconditions to a waitset", "attach_condition returned RETCODE: " + resultCode[0] + " " + resultCode[1] + " " + resultCode[2], expVerdict, Test.Framework.TestVerdict.Fail); continueTesting = false; } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (continueTesting) { ddsReturnCode = waitset.GetConditions(ref holder); if (ddsReturnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE: " + ddsReturnCode, expVerdict, Test.Framework.TestVerdict.Fail); } else { result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK" , expVerdict, Test.Framework.TestVerdict.Pass); } if (holder.Length != 3) { result = new Test.Framework.TestResult(expResult, "Did not resolve 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Fail); } else { if ((holder[0] != condition1) && (holder[1] != condition1) && (holder[2] != condition1)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (1)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if ((holder[0] != condition2) && (holder[1] != condition2) && (holder[2] != condition2)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (2)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if ((holder[0] != condition3) && (holder[1] != condition3) && (holder[2] != condition3)) { result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (3)" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, "Resolved 3 GuardCondition objects" , expVerdict, Test.Framework.TestVerdict.Pass); } } return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "DomainParticipantQos get/set succeeded."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos pqosHolder = null; DDS.DomainParticipantQos pqosHolder2 = null; DDS.ReturnCode returnCode; byte[] ud; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could be initialised." , expVerdict, Test.Framework.TestVerdict.Pass); if (factory.GetDefaultParticipantQos(ref pqosHolder) != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } pqosHolder.EntityFactory.AutoenableCreatedEntities = true; ud = new byte[1]; ud[0] = System.Convert.ToByte("4"); pqosHolder.UserData.Value = ud; pqosHolder.WatchdogScheduling.SchedulingClass.Kind = DDS.SchedulingClassQosPolicyKind.ScheduleRealtime; pqosHolder.WatchdogScheduling.SchedulingPriorityKind.Kind = DDS.SchedulingPriorityQosPolicyKind.PriorityAbsolute; pqosHolder.WatchdogScheduling.SchedulingPriority = 10; pqosHolder.ListenerScheduling.SchedulingClass.Kind = DDS.SchedulingClassQosPolicyKind.ScheduleTimesharing; pqosHolder.ListenerScheduling.SchedulingPriorityKind.Kind = DDS.SchedulingPriorityQosPolicyKind.PriorityAbsolute; pqosHolder.ListenerScheduling.SchedulingPriority = 20; returnCode = factory.SetDefaultParticipantQos(pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Set default participant qos failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant.GetQos(ref pqosHolder2); if (pqosHolder.UserData.Value.Length != pqosHolder2.UserData.Value.Length) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.UserData.Value[0] != pqosHolder2.UserData.Value[0]) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one (2)." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = participant.SetQos(pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "set_qos on DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant.GetQos(ref pqosHolder2); if (pqosHolder.UserData.Value.Length != pqosHolder2.UserData.Value. Length) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.UserData.Value[0] != pqosHolder2.UserData.Value[0]) { result = new Test.Framework.TestResult(expResult, "Resolved UserData policy does not match the applied one (2)." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.WatchdogScheduling.SchedulingClass.Kind != pqosHolder2.WatchdogScheduling.SchedulingClass.Kind) { result = new Test.Framework.TestResult(expResult, "Resolved watchdog_scheduling.scheduling_class policy does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.WatchdogScheduling.SchedulingPriorityKind.Kind != pqosHolder2.WatchdogScheduling.SchedulingPriorityKind.Kind) { result = new Test.Framework.TestResult(expResult, "Resolved watchdog_scheduling.scheduling_priority_kind policy does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.WatchdogScheduling.SchedulingPriority != pqosHolder2.WatchdogScheduling.SchedulingPriority) { result = new Test.Framework.TestResult(expResult, "Resolved watchdog_scheduling.SchedulingPriority does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.ListenerScheduling.SchedulingClass.Kind != pqosHolder2.ListenerScheduling.SchedulingClass.Kind) { result = new Test.Framework.TestResult(expResult, "Resolved listener_scheduling.scheduling_class policy does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.ListenerScheduling.SchedulingPriorityKind.Kind != pqosHolder2.ListenerScheduling.SchedulingPriorityKind.Kind) { result = new Test.Framework.TestResult(expResult, "Resolved listener_scheduling.scheduling_priority_kind policy does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (pqosHolder.ListenerScheduling.SchedulingPriority != pqosHolder2.ListenerScheduling.SchedulingPriority) { result = new Test.Framework.TestResult(expResult, "Resolved listener_scheduling.SchedulingPriority does not match the applied one" , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deletion of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Creating/deleting DomainParticipant succeeded."; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.IDomainParticipant participant2; DDS.DomainParticipantQos pqosHolder = null; DDS.ReturnCode returnCode; factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipantFactory could not be initialised." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.GetDefaultParticipantQos(ref pqosHolder); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Default DomainParticipantQos could not be resolved." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, pqosHolder);//, null, 0); if (participant == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could not be created." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } participant2 = factory.LookupParticipant(DDS.DomainId.Default); if (participant2 == null) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could not be looked up." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (participant != participant2) { result = new Test.Framework.TestResult(expResult, "Looked up DomainParticipant is not the same as the created one." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could not be deleted." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant2); if (returnCode == DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "DomainParticipant 2 could be deleted, but is was already gone." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode == DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "DomainParticipant could be deleted, but is was already gone." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(null); if (returnCode != DDS.ReturnCode.BadParameter) { result = new Test.Framework.TestResult("RETCODE_BAD_PARAMETER (RETCODE " + DDS.ReturnCode.BadParameter + ") after deletion of an invalid participant", "Return code " + returnCode + " was returned by factory.delete_participant", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } returnCode = factory.DeleteParticipant(participant); if (returnCode != DDS.ReturnCode.BadParameter) { result = new Test.Framework.TestResult("RETCODE_BAD_PARAMETER (RETCODE " + DDS.ReturnCode.BadParameter + ") after deletion of an invalid participant", "Return code " + returnCode + " was returned by factory.delete_participant", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } if (participant != null) { returnCode = participant.Enable(); if (returnCode == DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult("Enable on a deleted participant failed", "Enable on a deleted participant succeeded", Test.Framework.TestVerdict.Fail, Test.Framework.TestVerdict.Fail); return(result); } } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Waitset StatusCondition succeeded."; DDS.ICondition[] holder; DDS.ReturnCode rc; DDS.DomainParticipantFactory factory; DDS.IDomainParticipant participant; DDS.DomainParticipantQos qosHolder = null; DDS.IStatusCondition condition; DDS.IStatusCondition condition2; DDS.IPublisher publisher; DDS.PublisherQos pubQosHolder = null; result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict .Pass, Test.Framework.TestVerdict.Fail); holder = new DDS.ICondition[0]; DDS.WaitSet waitset = new DDS.WaitSet(); factory = DDS.DomainParticipantFactory.Instance; if (factory == null) { result.Result = "Factory get_instance failed."; return(result); } if (factory.GetDefaultParticipantQos(ref qosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_participant_qos failed."; return(result); } participant = factory.CreateParticipant(DDS.DomainId.Default, qosHolder);//, null, 0); if (participant == null) { result.Result = "create_participant failed."; return(result); } if (participant.GetDefaultPublisherQos(ref pubQosHolder) != DDS.ReturnCode.Ok) { result.Result = "get_default_publisher_qos failed."; return(result); } publisher = participant.CreatePublisher(pubQosHolder);//, null, DDS.StatusKind.Any); if (publisher == null) { result.Result = "create_publisher failed."; return(result); } condition = participant.StatusCondition; if (condition == null) { result.Result = "get_status_condition failed."; return(result); } condition2 = publisher.StatusCondition; if (condition2 == null) { result.Result = "get_status_condition failed.(2)"; return(result); } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return(result); } if (holder.Length != 1) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return(result); } if (holder[0] != condition) { result.Result = "get_conditions returned wrong condition."; return(result); } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (1)"; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc + " (1)"; return(result); } if (holder.Length != 0) { result.Result = "get_conditions returned " + holder.Length + " conditions (1)."; return(result); } rc = waitset.AttachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.AttachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "attach_condition returned RETCODE: " + rc; return(result); } rc = waitset.GetConditions(ref holder); if (rc != DDS.ReturnCode.Ok) { result.Result = "get_conditions returned RETCODE: " + rc; return(result); } if (holder.Length != 2) { result.Result = "get_conditions returned " + holder.Length + " conditions."; return(result); } if ((holder[0] != condition) && (holder[1] != condition)) { result.Result = "get_conditions returned wrong conditions(1)."; return(result); } if ((holder[0] != condition2) && (holder[1] != condition2)) { result.Result = "get_conditions returned wrong conditions(2)."; return(result); } rc = waitset.DetachCondition(condition); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (2)"; return(result); } rc = waitset.DetachCondition(condition2); if (rc != DDS.ReturnCode.Ok) { result.Result = "detach_condition returned RETCODE: " + rc + " (3)"; return(result); } rc = participant.DeleteContainedEntities(); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_contained_entities returned RETCODE: " + rc; return(result); } rc = factory.DeleteParticipant(participant); if (rc != DDS.ReturnCode.Ok) { result.Result = "delete_participant returned RETCODE: " + rc; return(result); } result.Result = expResult; result.Verdict = expVerdict; return(result); }
public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; DDS.ReturnCode status; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "Both uninitialized and initialized struct A can be written/received without errors."; DDS.IDomainParticipant participant; testDefConstr.ATypeSupport aTS; string aTypeName; DDS.ITopic aTopic; DDS.IPublisher pub; DDS.ISubscriber sub; testDefConstr.ADataWriter aDW; testDefConstr.ADataReader aDR; long handle; string resultMsg; // Create Participant. participant = DDS.DomainParticipantFactory.Instance.CreateParticipant(DDS.DomainId.Default); if (participant == null) { result = new Test.Framework.TestResult(expResult, "Creation of DomainParticipant failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Register TypeSupport. aTS = new testDefConstr.ATypeSupport(); aTypeName = aTS.TypeName; status = aTS.RegisterType(participant, aTypeName); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Registering of A TypeSupport failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Topic. aTopic = participant.CreateTopic("structA", aTypeName); if (aTopic == null) { result = new Test.Framework.TestResult(expResult, "Creation of A Topic failed.", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Publisher. pub = participant.CreatePublisher(); if (pub == null) { result = new Test.Framework.TestResult(expResult, "Creation of Publisher failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create ADataWriter. aDW = pub.CreateDataWriter(aTopic) as testDefConstr.ADataWriter;; if (aDW == null) { result = new Test.Framework.TestResult(expResult, "Creation of ADataWriter failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Subscriber. sub = participant.CreateSubscriber(); if (pub == null) { result = new Test.Framework.TestResult(expResult, "Creation of Subscriber failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create ADataReader. aDR = sub.CreateDataReader(aTopic) as testDefConstr.ADataReader; if (aDR == null) { result = new Test.Framework.TestResult(expResult, "Creation of ADataReader failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Instantiate a sample of A and test if it is initialized properly. testDefConstr.A myA = new testDefConstr.A(); resultMsg = TestInit(myA); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Default initialization of A not successful: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Register the sample and write it into the system. handle = aDW.RegisterInstance(myA); if (handle == 0) { result = new Test.Framework.TestResult(expResult, "Registering an instance of type A failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = aDW.Write(myA, handle); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Writing an instance of type A failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Read the sample and check whether everything is initialized properly. testDefConstr.A[] msgSeq = null; DDS.SampleInfo[] infoSeq = null; status = aDR.Take(ref msgSeq, ref infoSeq, DDS.Length.Unlimited, DDS.SampleStateKind.NotRead, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Alive); if (msgSeq.Length != 1) { result = new Test.Framework.TestResult(expResult, "Wrong number of samples received." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } resultMsg = TestInit(msgSeq[0]); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Received A Sample has a different state from its orginial: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } //Now explicitly initlaize sample to some preset values. myA.id = 5; myA.name = "Mary"; myA.embedded.x = 1; myA.embedded.y = 2; myA.embedded.z = 3; myA.c = testDefConstr.Color.Blue; for (int i = 0; i < testDefConstr.DIM_NUMS_1.value; i++) { for (int j = 0; j < testDefConstr.DIM_NUMS_2.value; j++) { myA.nums[i, j] = 10 + i + j; } } myA.nums2 = new int[2][]; myA.nums2[0] = new int[1]; myA.nums2[1] = new int[1]; myA.nums2[0][0] = 8; myA.nums2[1][0] = 9; myA.floatList = new float[1][]; myA.floatList[0] = new float[2]; myA.floatList[0][0] = 0.1f; myA.floatList[0][1] = 0.2f; myA.stringList = new string[3] { "Erik", "Maurtis", "Hans" }; for (int i = 0; i < testDefConstr.DIM_LA2DIM_1.value; i++) { for (int j = 0; j < testDefConstr.DIM_LONGARRAY10_1.value; j++) { myA.la2Dim[i, j] = testDefConstr.DIM_LA2DIM_1.value * i + j; } } // Register the sample and write it into the system. handle = aDW.RegisterInstance(myA); if (handle == 0) { result = new Test.Framework.TestResult(expResult, "Registering an initialized instance of type A failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = aDW.Write(myA, handle); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Writing an initialized instance of type A failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Read the sample and check whether everything is initialized properly. status = aDR.Take(ref msgSeq, ref infoSeq, DDS.Length.Unlimited, DDS.SampleStateKind.NotRead, DDS.ViewStateKind.Any, DDS.InstanceStateKind.Alive); if (msgSeq.Length != 1) { result = new Test.Framework.TestResult(expResult, "Wrong number of samples received." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } resultMsg = compareSamples(myA, msgSeq[0]); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Received A Sample has a different state from its orginial: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Delete all entities. status = participant.DeleteContainedEntities(); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deleting contained entities failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = DDS.DomainParticipantFactory.Instance.DeleteParticipant(participant); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Deleting participant failed.", expVerdict, Test.Framework.TestVerdict.Fail); return(result); } result = new Test.Framework.TestResult(expResult, expResult, expVerdict, expVerdict ); return(result); }