public void TestOneofTypes_Message() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); Assert.AreEqual(builder.FooMessage.QuxInt, 0); builder.SetFooMessage(TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()); Assert.IsTrue(builder.HasFooMessage); Assert.AreEqual(builder.FooMessage.QuxInt, 234); TestOneof2 message = builder.BuildPartial(); Assert.IsTrue(message.HasFooMessage); Assert.AreEqual(message.FooMessage.QuxInt, 234); Assert.IsFalse(builder.ClearFooMessage().HasFooMessage); message = builder.Build(); Assert.IsFalse(message.HasFooMessage); Assert.AreEqual(message.FooMessage.QuxInt, 0); builder = TestOneof2.CreateBuilder(); Assert.IsFalse(builder.HasFooMessage); builder.SetFooMessage(TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(123)); Assert.IsTrue(builder.HasFooMessage); Assert.AreEqual(builder.FooMessage.QuxInt, 123); message = builder.Build(); Assert.IsTrue(message.HasFooMessage); Assert.AreEqual(message.FooMessage.QuxInt, 123); }