public void TestMessageMissingExtensions() { TestXmlMessage original = TestXmlMessage.CreateBuilder() .SetValid(true) .SetText("text") .SetExtension(UnittestExtrasXmltest.ExtensionText, " extension text value ! ") .SetExtension(UnittestExtrasXmltest.ExtensionMessage, new TestXmlExtension.Builder().SetNumber(42).Build()) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 100) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 101) .AddExtension(UnittestExtrasXmltest.ExtensionNumber, 102) .SetExtension(UnittestExtrasXmltest.ExtensionEnum, EnumOptions.ONE) .Build(); TestXmlMessage message = original.ToBuilder() .ClearExtension(UnittestExtrasXmltest.ExtensionText) .ClearExtension(UnittestExtrasXmltest.ExtensionMessage) .ClearExtension(UnittestExtrasXmltest.ExtensionNumber) .ClearExtension(UnittestExtrasXmltest.ExtensionEnum) .Build(); JsonFormatWriter writer = JsonFormatWriter.CreateInstance(); writer.WriteMessage(original); Content = writer.ToString(); IMessageLite copy = JsonFormatReader.CreateInstance(Content) .Merge(message.CreateBuilderForType()).Build(); Assert.AreNotEqual(original, message); Assert.AreNotEqual(original, copy); Assert.AreEqual(message, copy); }