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); }
public void TestOneofTypes_Enum() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); Assert.AreEqual(builder.FooEnum, TestOneof2.Types.NestedEnum.FOO); Assert.IsTrue(builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).HasFooEnum); Assert.AreEqual(builder.FooEnum, TestOneof2.Types.NestedEnum.BAR); TestOneof2 message = builder.BuildPartial(); Assert.IsTrue(message.HasFooEnum); Assert.AreEqual(message.FooEnum, TestOneof2.Types.NestedEnum.BAR); Assert.IsFalse(builder.ClearFooEnum().HasFooEnum); TestOneof2 message2 = builder.Build(); Assert.IsFalse(message2.HasFooEnum); Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.FOO); }
public void TestOneofTypes_Primitive() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); Assert.AreEqual(builder.FooInt, 0); Assert.IsFalse(builder.HasFooInt); Assert.IsTrue(builder.SetFooInt(123).HasFooInt); Assert.AreEqual(builder.FooInt, 123); TestOneof2 message = builder.BuildPartial(); Assert.IsTrue(message.HasFooInt); Assert.AreEqual(message.FooInt, 123); Assert.IsFalse(builder.ClearFooInt().HasFooInt); TestOneof2 message2 = builder.Build(); Assert.IsFalse(message2.HasFooInt); Assert.AreEqual(message2.FooInt, 0); }
public void TestOneofTypes_String() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); Assert.AreEqual(builder.FooString, ""); Assert.IsTrue(builder.SetFooString("foo").HasFooString); Assert.AreEqual(builder.FooString, "foo"); TestOneof2 message = builder.BuildPartial(); Assert.IsTrue(message.HasFooString); Assert.AreEqual(message.FooString, "foo"); Assert.IsFalse(builder.ClearFooString().HasFooString); TestOneof2 message2 = builder.Build(); Assert.IsFalse(message2.HasFooString); Assert.AreEqual(message2.FooString, ""); builder.SetFooInt(123); Assert.AreEqual(builder.FooString, ""); Assert.AreEqual(builder.FooInt, 123); message = builder.Build(); Assert.AreEqual(message.FooString, ""); Assert.AreEqual(message.FooInt, 123); }