Example #1
0
        public void MergeFromDynamic()
        {
            TestAllTypes result = (TestAllTypes)TestAllTypes.CreateBuilder(MergeDest)
                                  .MergeFrom(DynamicMessage.CreateBuilder(MergeSource).Build())
                                  .Build();

            Assert.AreEqual(MergeResultText, result.ToString());
        }
        public void WrongTypeTreatedAsUnknown()
        {
            // Test that fields of the wrong wire type are treated like unknown fields
            // when parsing.

            ByteString       bizarroData     = GetBizarroData();
            TestAllTypes     allTypesMessage = TestAllTypes.ParseFrom(bizarroData);
            TestEmptyMessage emptyMessage    = TestEmptyMessage.ParseFrom(bizarroData);

            // All fields should have been interpreted as unknown, so the debug strings
            // should be the same.
            Assert.AreEqual(emptyMessage.ToString(), allTypesMessage.ToString());
        }
Example #3
0
        public void MergeFrom()
        {
            TestAllTypes result = TestAllTypes.CreateBuilder(MergeDest).MergeFrom(MergeSource).Build();

            Assert.AreEqual(MergeResultText, result.ToString());
        }
        public void CustomDiagnosticMessage_Nested()
        {
            var message = new TestAllTypes {
                SingleForeignMessage = new ForeignMessage {
                    C = 16
                }
            };

            Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
            Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
        }
Example #5
0
 public void CustomDiagnosticMessage_Nested()
 {
     var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } };
     Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
     Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
 }