public void WriteTo(pb.CodedOutputStream output) { #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE output.WriteRawMessage(this); #else if (ClientId.Length != 0) { output.WriteRawTag(10); output.WriteString(ClientId); } if (MessageId.Length != 0) { output.WriteRawTag(18); output.WriteString(MessageId); } if (Type != MessageType.Undefined) { output.WriteRawTag(24); output.WriteEnum((int)Type); } if (time_ != null) { output.WriteRawTag(34); output.WriteMessage(Time); } if (Status != MessageStatus.Undefined) { output.WriteRawTag(40); output.WriteEnum((int)Status); } if (Payload.Length != 0) { output.WriteRawTag(50); output.WriteBytes(Payload); } if (Response != ResponseType.Undefined) { output.WriteRawTag(56); output.WriteEnum((int)Response); } if (_unknownFields != null) { _unknownFields.WriteTo(output); } #endif }
public void TestNegativeEnumNoTag() { Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); byte[] bytes = new byte[10]; CodedOutputStream output = CodedOutputStream.CreateInstance(bytes); output.WriteEnum((int) SampleEnum.NegativeValue); Assert.AreEqual(0, output.SpaceLeft); Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); }
public void TestNegativeEnumNoTag() { Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2)); Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue)); byte[] bytes = new byte[10]; CodedOutputStream output = new CodedOutputStream(bytes); output.WriteEnum((int) SampleEnum.NegativeValue); Assert.AreEqual(0, output.SpaceLeft); Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes)); }