public void testDynamicMessagePackedParsing() { TestPackedTypes.Builder builder = TestPackedTypes.CreateBuilder(); TestUtil.SetPackedFields(builder); TestPackedTypes message = builder.Build(); ByteString rawBytes = message.ToByteString(); IMessage message2 = DynamicMessage.ParseFrom(TestPackedTypes.Descriptor, rawBytes); packedReflectionTester.AssertPackedFieldsSetViaReflection(message2); }
public void PackedParsing() { AbstractMessageWrapper.Builder builder = new AbstractMessageWrapper.Builder(TestPackedTypes.CreateBuilder()); AbstractMessageWrapper message = builder.MergeFrom(TestUtil.GetPackedSet().ToByteString()).Build(); TestUtil.AssertPackedFieldsSet((TestPackedTypes)message.WrappedMessage); }
public void TestRoundTripPackedTypes() { TestPackedTypes msg = AddPackedTypes(new TestPackedTypes.Builder(), 5).Build(); object content = SerializeMessage <TestPackedTypes, TestPackedTypes.Builder>(msg); TestPackedTypes copy = DeserializeMessage <TestPackedTypes, TestPackedTypes.Builder>(content, TestPackedTypes.CreateBuilder(), ExtensionRegistry.Empty).Build(); Assert.AreEqual(msg, copy); AssertOutputEquals(content, SerializeMessage <TestPackedTypes, TestPackedTypes.Builder>(copy)); Assert.AreEqual(Convert.ToBase64String(msg.ToByteArray()), Convert.ToBase64String(copy.ToByteArray())); }