コード例 #1
0
        public void TestIBuilderLiteWeakMergeFromByteStringExtensions()
        {
            TestAllExtensionsLite copy,
                                  msg = TestAllExtensionsLite.CreateBuilder()
                                        .SetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite,
                                                      "Should be merged.").Build();

            copy = TestAllExtensionsLite.DefaultInstance;
            Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());

            copy =
                (TestAllExtensionsLite)
                ((IBuilderLite)copy.ToBuilder()).WeakMergeFrom(msg.ToByteString(), ExtensionRegistry.Empty).WeakBuild();
            Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            copy =
                (TestAllExtensionsLite)
                ((IBuilderLite)copy.ToBuilder()).WeakMergeFrom(msg.ToByteString(), registry).WeakBuild();
            TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
            Assert.AreEqual("Should be merged.", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
        }
コード例 #2
0
        public void ExtensionWriterTestMessages()
        {
            TestAllExtensionsLite.Builder b = TestAllExtensionsLite.CreateBuilder().SetExtension(
                UnitTestLiteProtoFile.OptionalForeignMessageExtensionLite, ForeignMessageLite.CreateBuilder().SetC(123).Build());
            TestAllExtensionsLite copy, msg = b.Build();

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry);
            Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
        }
コード例 #3
0
        public void TestUnpackedFromPackedInput()
        {
            byte[] packedData = BuildPackedExtensions().ToByteArray();

            TestUnpackedTypesLite unpacked = TestUnpackedTypesLite.ParseFrom(packedData);
            TestPackedTypesLite   packed   = TestPackedTypesLite.ParseFrom(unpacked.ToByteArray());

            TestUtil.AssertBytesEqual(packedData, packed.ToByteArray());

            unpacked = TestUnpackedTypesLite.ParseFrom(packed.ToByteArray());

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);
            AssertPackedExtensions(TestPackedExtensionsLite.ParseFrom(unpacked.ToByteArray(), registry));
        }
コード例 #4
0
        public void ExtensionWriterTestPacked()
        {
            TestPackedExtensionsLite msg = BuildPackedExtensions();

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            TestPackedExtensionsLite.Builder copyBuilder =
                TestPackedExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry);
            TestPackedExtensionsLite copy = copyBuilder.Build();

            TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());

            AssertPackedExtensions(copy);
        }
コード例 #5
0
        public void TestUnpackedAndPackedExtensions()
        {
            TestPackedExtensionsLite original = BuildPackedExtensions();

            AssertPackedExtensions(original);

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);
            UnitTestExtrasLiteProtoFile.RegisterAllExtensions(registry);

            TestUnpackedExtensionsLite unpacked = TestUnpackedExtensionsLite.ParseFrom(original.ToByteArray(), registry);

            TestPackedExtensionsLite packed = TestPackedExtensionsLite.ParseFrom(unpacked.ToByteArray(), registry);

            Assert.AreEqual(original, packed);
            TestUtil.AssertBytesEqual(original.ToByteArray(), packed.ToByteArray());
            AssertPackedExtensions(packed);
        }
コード例 #6
0
        public void ExtensionWriterTestSetExtensionLists()
        {
            TestAllExtensionsLite msg, copy;

            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .SetExtension(UnitTestLiteProtoFile.RepeatedBoolExtensionLite, new[] { true, false })
                                                    .SetExtension(UnitTestLiteProtoFile.RepeatedCordExtensionLite, new[] { "123", "456" })
                                                    .SetExtension(UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite, new[] { ForeignEnumLite.FOREIGN_LITE_BAZ, ForeignEnumLite.FOREIGN_LITE_FOO })
            ;

            msg = builder.Build();
            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            copy = TestAllExtensionsLite.ParseFrom(msg.ToByteArray(), registry);
            Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());

            Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_FOO, copy.GetExtension(UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite, 1));
        }
コード例 #7
0
        public void TestBuilderLiteMergeFromStreamExtensions()
        {
            TestAllExtensionsLite copy, msg = TestAllExtensionsLite.CreateBuilder()
                                              .SetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite, "Should be merged.").Build();

            copy = TestAllExtensionsLite.DefaultInstance;
            Assert.AreNotEqual(msg.ToByteArray(), copy.ToByteArray());

            Stream s = new MemoryStream();

            msg.WriteTo(s);
            s.Position = 0;

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            copy = copy.ToBuilder().MergeFrom(s, registry).Build();
            Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());
            Assert.AreEqual("Should be merged.", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
        }
コード例 #8
0
        public void ExtensionWriterTest()
        {
            TestAllExtensionsLite.Builder builder = TestAllExtensionsLite.CreateBuilder()
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultBoolExtensionLite, true)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultBytesExtensionLite, ByteString.CopyFromUtf8("123"))
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultCordExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultDoubleExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultFixed32ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultFixed64ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultFloatExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultInt32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultInt64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultNestedEnumExtensionLite,
                                                                  TestAllTypesLite.Types.NestedEnum.FOO)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultSfixed32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultSfixed64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultSint32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultSint64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultStringExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultStringPieceExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultUint32ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.DefaultUint64ExtensionLite, 123u)
                                                    //Optional
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalBoolExtensionLite, true)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalBytesExtensionLite, ByteString.CopyFromUtf8("123"))
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalCordExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalDoubleExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalFixed32ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalFixed64ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalFloatExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalInt64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalNestedEnumExtensionLite,
                                                                  TestAllTypesLite.Types.NestedEnum.FOO)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalSfixed32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalSfixed64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalSint32ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalSint64ExtensionLite, 123)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalStringPieceExtensionLite, "123")
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalUint32ExtensionLite, 123u)
                                                    .SetExtension(UnitTestLiteProtoFile.OptionalUint64ExtensionLite, 123u)
                                                    //Repeated
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedBoolExtensionLite, true)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedBytesExtensionLite, ByteString.CopyFromUtf8("123"))
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedCordExtensionLite, "123")
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedDoubleExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedFixed32ExtensionLite, 123u)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedFixed64ExtensionLite, 123u)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedFloatExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite, ForeignEnumLite.FOREIGN_LITE_BAZ)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedInt64ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedNestedEnumExtensionLite,
                                                                  TestAllTypesLite.Types.NestedEnum.FOO)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedSfixed32ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedSfixed64ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedSint32ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedSint64ExtensionLite, 123)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedStringExtensionLite, "123")
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedStringPieceExtensionLite, "123")
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedUint32ExtensionLite, 123u)
                                                    .AddExtension(UnitTestLiteProtoFile.RepeatedUint64ExtensionLite, 123u)
            ;
            TestAllExtensionsLite msg = builder.Build();

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            TestAllExtensionsLite.Builder copyBuilder =
                TestAllExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry);
            TestAllExtensionsLite copy = copyBuilder.Build();

            TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());

            Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.DefaultBoolExtensionLite));
            Assert.AreEqual(ByteString.CopyFromUtf8("123"),
                            copy.GetExtension(UnitTestLiteProtoFile.DefaultBytesExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.DefaultCordExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultDoubleExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.DefaultFixed32ExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.DefaultFixed64ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultFloatExtensionLite));
            Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.DefaultForeignEnumExtensionLite));
            Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.DefaultImportEnumExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultInt32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultInt64ExtensionLite));
            Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO,
                            copy.GetExtension(UnitTestLiteProtoFile.DefaultNestedEnumExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultSfixed32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultSfixed64ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultSint32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.DefaultSint64ExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.DefaultStringExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.DefaultStringPieceExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.DefaultUint32ExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.DefaultUint64ExtensionLite));

            Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.OptionalBoolExtensionLite));
            Assert.AreEqual(ByteString.CopyFromUtf8("123"),
                            copy.GetExtension(UnitTestLiteProtoFile.OptionalBytesExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.OptionalCordExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalDoubleExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.OptionalFixed32ExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.OptionalFixed64ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalFloatExtensionLite));
            Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.OptionalForeignEnumExtensionLite));
            Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.OptionalImportEnumExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalInt32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalInt64ExtensionLite));
            Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO,
                            copy.GetExtension(UnitTestLiteProtoFile.OptionalNestedEnumExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalSfixed32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalSfixed64ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalSint32ExtensionLite));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.OptionalSint64ExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringExtensionLite));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.OptionalStringPieceExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.OptionalUint32ExtensionLite));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.OptionalUint64ExtensionLite));

            Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.RepeatedBoolExtensionLite, 0));
            Assert.AreEqual(ByteString.CopyFromUtf8("123"),
                            copy.GetExtension(UnitTestLiteProtoFile.RepeatedBytesExtensionLite, 0));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.RepeatedCordExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedDoubleExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.RepeatedFixed32ExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.RepeatedFixed64ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedFloatExtensionLite, 0));
            Assert.AreEqual(ForeignEnumLite.FOREIGN_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.RepeatedForeignEnumExtensionLite, 0));
            Assert.AreEqual(ImportEnumLite.IMPORT_LITE_BAZ,
                            copy.GetExtension(UnitTestLiteProtoFile.RepeatedImportEnumExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedInt32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedInt64ExtensionLite, 0));
            Assert.AreEqual(TestAllTypesLite.Types.NestedEnum.FOO,
                            copy.GetExtension(UnitTestLiteProtoFile.RepeatedNestedEnumExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedSfixed32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedSfixed64ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedSint32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.RepeatedSint64ExtensionLite, 0));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.RepeatedStringExtensionLite, 0));
            Assert.AreEqual("123", copy.GetExtension(UnitTestLiteProtoFile.RepeatedStringPieceExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.RepeatedUint32ExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.RepeatedUint64ExtensionLite, 0));
        }
コード例 #9
0
        public void ExtensionWriterTestPacked()
        {
            TestPackedExtensionsLite.Builder builder = TestPackedExtensionsLite.CreateBuilder()
                                                       .AddExtension(UnitTestLiteProtoFile.PackedBoolExtensionLite, true)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedDoubleExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFixed32ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFixed64ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFloatExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedInt32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedInt64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSfixed32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSfixed64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSint32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSint64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedUint32ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedUint64ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedBoolExtensionLite, true)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedDoubleExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFixed32ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFixed64ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedFloatExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedInt32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedInt64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSfixed32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSfixed64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSint32ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedSint64ExtensionLite, 123)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedUint32ExtensionLite, 123u)
                                                       .AddExtension(UnitTestLiteProtoFile.PackedUint64ExtensionLite, 123u);

            TestPackedExtensionsLite msg = builder.Build();

            ExtensionRegistry registry = ExtensionRegistry.CreateInstance();

            UnitTestLiteProtoFile.RegisterAllExtensions(registry);

            TestPackedExtensionsLite.Builder copyBuilder = TestPackedExtensionsLite.CreateBuilder().MergeFrom(msg.ToByteArray(), registry);
            TestPackedExtensionsLite         copy        = copyBuilder.Build();

            Assert.AreEqual(msg.ToByteArray(), copy.ToByteArray());

            Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.PackedBoolExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedDoubleExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedFixed32ExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedFixed64ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedFloatExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedInt32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedInt64ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSfixed32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSfixed64ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSint32ExtensionLite, 0));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSint64ExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedUint32ExtensionLite, 0));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedUint64ExtensionLite, 0));

            Assert.AreEqual(true, copy.GetExtension(UnitTestLiteProtoFile.PackedBoolExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedDoubleExtensionLite, 1));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedFixed32ExtensionLite, 1));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedFixed64ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedFloatExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedInt32ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedInt64ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSfixed32ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSfixed64ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSint32ExtensionLite, 1));
            Assert.AreEqual(123, copy.GetExtension(UnitTestLiteProtoFile.PackedSint64ExtensionLite, 1));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedUint32ExtensionLite, 1));
            Assert.AreEqual(123u, copy.GetExtension(UnitTestLiteProtoFile.PackedUint64ExtensionLite, 1));
        }