예제 #1
0
        public void Merge()
        {
            // Only test a simple case here and expect
            // {@link FieldMaskTreeTest#Merge} to cover all scenarios.
            FieldMask          fieldMask = FieldMask.FromString("payload");
            NestedTestAllTypes source    = new NestedTestAllTypes
            {
                Payload = new TestAllTypes
                {
                    SingleInt32   = 1234,
                    SingleFixed64 = 4321
                }
            };
            NestedTestAllTypes destination = new NestedTestAllTypes();

            fieldMask.Merge(source, destination);
            Assert.AreEqual(1234, destination.Payload.SingleInt32);
            Assert.AreEqual(4321, destination.Payload.SingleFixed64);

            destination = new NestedTestAllTypes
            {
                Payload = new TestAllTypes
                {
                    SingleInt32 = 4321,
                    SingleInt64 = 5678
                }
            };
            fieldMask.Merge(source, destination);
            Assert.AreEqual(1234, destination.Payload.SingleInt32);
            Assert.AreEqual(5678, destination.Payload.SingleInt64);
            Assert.AreEqual(4321, destination.Payload.SingleFixed64);
        }