public void TestGetKeyValue() { // Initialize entities DataWriter writer = _publisher.CreateDataWriter(_topic); Assert.IsNotNull(writer); TestStructDataWriter dataWriter = new TestStructDataWriter(writer); // Call GetKeyValue with HandleNil TestStruct data = new TestStruct(); ReturnCode result = dataWriter.GetKeyValue(data, InstanceHandle.HandleNil); Assert.AreEqual(ReturnCode.BadParameter, result); // Register an instance TestStruct instance = new TestStruct { Id = 1 }; InstanceHandle handle = dataWriter.RegisterInstance(instance); Assert.AreNotEqual(InstanceHandle.HandleNil, handle); // Call GetKeyValue data = new TestStruct(); result = dataWriter.GetKeyValue(data, handle); Assert.AreEqual(ReturnCode.Ok, result); Assert.AreEqual(1, data.Id); }