public override Test.Framework.TestResult Run() { Test.Framework.TestResult result; int status; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "uninitialized struct StructBigTest can be written/received without errors."; DDS.IDomainParticipant participant; testDefConstr.StructBigTestTypeSupport sbtTS; string sbtTypeName; DDS.ITopic sbtTopic; DDS.IPublisher pub; DDS.ISubscriber sub; DDS.IDataWriter dw; testDefConstr.StructBigTestDataWriter sbtDW; DDS.IDataReader dr; testDefConstr.StructBigTestDataReader sbtDR; long handle; string resultMsg; // Create Participant. participant = DDS.TheParticipantFactory.Value.CreateParticipant(null, 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. sbtTS = new testDefConstr.StructBigTestTypeSupport(); sbtTypeName = sbtTS.TypeName; status = sbtTS.RegisterType(participant, sbtTypeName); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Registering of StructBigTest TypeSupport failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Create Topic. sbtTopic = participant.CreateTopic("StructBigTest", sbtTypeName, DDS.TOPIC_QOS_DEFAULT .Value, null, 0); if (sbtTopic == null) { result = new Test.Framework.TestResult(expResult, "Creation of StructBigTest 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(sbtTopic, DDS.DATAWRITER_QOS_USE_TOPIC_QOS.Value, null , 0); sbtDW = testDefConstr.StructBigTestDataWriterHelper.Narrow(dw); if (sbtDW == null) { result = new Test.Framework.TestResult(expResult, "Creation of StructBigTestDataWriter 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(sbtTopic, DDS.DATAREADER_QOS_USE_TOPIC_QOS.Value, null , 0); sbtDR = testDefConstr.StructBigTestDataReaderHelper.Narrow(dr); if (sbtDR == 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.StructBigTest sbt = new testDefConstr.StructBigTest(); resultMsg = TestInit(sbt); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Default initialization of StructBigTest not successful: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Register the sample and write it into the system. handle = sbtDW.Register_instance(sbt); if (handle == 0) { result = new Test.Framework.TestResult(expResult, "Registering an instance of type StructBigTest failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } status = sbtDW.Write(sbt, handle); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Writing an instance of type StructBigTest failed." , expVerdict, Test.Framework.TestVerdict.Fail); return(result); } // Read the sample and check whether everything is initialized properly. testDefConstr.StructBigTestSeqHolder msgSeq = new testDefConstr.StructBigTestSeqHolder (); DDS.SampleInfo[] infoSeq = new DDS.SampleInfo[] (); status = sbtDR.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 StructBigTest 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; int status; Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass; string expResult = "uninitialized struct StructBigTest can be written/received without errors."; DDS.IDomainParticipant participant; testDefConstr.StructBigTestTypeSupport sbtTS; string sbtTypeName; DDS.ITopic sbtTopic; DDS.IPublisher pub; DDS.ISubscriber sub; DDS.IDataWriter dw; testDefConstr.StructBigTestDataWriter sbtDW; DDS.IDataReader dr; testDefConstr.StructBigTestDataReader sbtDR; long handle; string resultMsg; // Create Participant. participant = DDS.TheParticipantFactory.Value.CreateParticipant(null, 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. sbtTS = new testDefConstr.StructBigTestTypeSupport(); sbtTypeName = sbtTS.TypeName; status = sbtTS.RegisterType(participant, sbtTypeName); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Registering of StructBigTest TypeSupport failed." , expVerdict, Test.Framework.TestVerdict.Fail); return result; } // Create Topic. sbtTopic = participant.CreateTopic("StructBigTest", sbtTypeName, DDS.TOPIC_QOS_DEFAULT .Value, null, 0); if (sbtTopic == null) { result = new Test.Framework.TestResult(expResult, "Creation of StructBigTest 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(sbtTopic, DDS.DATAWRITER_QOS_USE_TOPIC_QOS.Value, null , 0); sbtDW = testDefConstr.StructBigTestDataWriterHelper.Narrow(dw); if (sbtDW == null) { result = new Test.Framework.TestResult(expResult, "Creation of StructBigTestDataWriter 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(sbtTopic, DDS.DATAREADER_QOS_USE_TOPIC_QOS.Value, null , 0); sbtDR = testDefConstr.StructBigTestDataReaderHelper.Narrow(dr); if (sbtDR == 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.StructBigTest sbt = new testDefConstr.StructBigTest(); resultMsg = TestInit(sbt); if (resultMsg != null) { result = new Test.Framework.TestResult(expResult, "Default initialization of StructBigTest not successful: " + resultMsg, expVerdict, Test.Framework.TestVerdict.Fail); return result; } // Register the sample and write it into the system. handle = sbtDW.Register_instance(sbt); if (handle == 0) { result = new Test.Framework.TestResult(expResult, "Registering an instance of type StructBigTest failed." , expVerdict, Test.Framework.TestVerdict.Fail); return result; } status = sbtDW.Write(sbt, handle); if (status != DDS.ReturnCode.Ok) { result = new Test.Framework.TestResult(expResult, "Writing an instance of type StructBigTest failed." , expVerdict, Test.Framework.TestVerdict.Fail); return result; } // Read the sample and check whether everything is initialized properly. testDefConstr.StructBigTestSeqHolder msgSeq = new testDefConstr.StructBigTestSeqHolder (); DDS.SampleInfo[] infoSeq = new DDS.SampleInfo[](); status = sbtDR.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 StructBigTest 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; }