public void TestClone() { var message = new TestAllExtensions(); message.SetExtension(OptionalBoolExtension, true); var other = message.Clone(); Assert.AreEqual(message, other); Assert.AreEqual(message.CalculateSize(), message.CalculateSize()); }
public void TestMergeMessage() { var message = new TestAllExtensions(); message.SetExtension(OptionalBoolExtension, true); var other = new TestAllExtensions(); Assert.AreNotEqual(message, other); Assert.AreNotEqual(message.CalculateSize(), other.CalculateSize()); other.MergeFrom(message); Assert.AreEqual(message, other); Assert.AreEqual(message.CalculateSize(), other.CalculateSize()); }
public void TestMergeCodedInput() { var message = new TestAllExtensions(); message.SetExtension(OptionalBoolExtension, true); var serialized = message.ToByteArray(); var other = TestAllExtensions.Parser .WithExtensionRegistry(new ExtensionRegistry() { OptionalBoolExtension }) .ParseFrom(serialized); Assert.AreEqual(message, other); Assert.AreEqual(message.CalculateSize(), other.CalculateSize()); }
public void TestMergeCodedInput() { var message = new TestAllExtensions(); message.SetExtension(OptionalBoolExtension, true); var serialized = message.ToByteArray(); MessageParsingHelpers.AssertReadingMessage( TestAllExtensions.Parser.WithExtensionRegistry(new ExtensionRegistry() { OptionalBoolExtension }), serialized, other => { Assert.AreEqual(message, other); Assert.AreEqual(message.CalculateSize(), other.CalculateSize()); }); }