public void TestSetOneofClearsOthers() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); TestOneof2 message = builder.SetFooInt(123).SetFooString("foo").Build(); Assert.IsTrue(message.HasFooString); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooCord("bar").Build(); Assert.IsTrue(message.HasFooCord); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooStringPiece("baz").Build(); Assert.IsTrue(message.HasFooStringPiece); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooBytes(TestUtil.ToBytes("qux")).Build(); Assert.IsTrue(message.HasFooBytes); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.FOO).Build(); Assert.IsTrue(message.HasFooEnum); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooMessage( TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()).Build(); Assert.IsTrue(message.HasFooMessage); TestUtil.AssertAtMostOneFieldSetOneof(message); message = builder.SetFooInt(123).Build(); Assert.IsTrue(message.HasFooInt); TestUtil.AssertAtMostOneFieldSetOneof(message); }