public void TestOneofSerialization_String() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); TestOneof2 message = builder.SetFooString("foo").Build(); ByteString serialized = message.ToByteString(); TestOneof2 message2 = TestOneof2.ParseFrom(serialized); Assert.IsTrue(message2.HasFooString); Assert.AreEqual(message2.FooString, "foo"); }
public void TestOneofSerialization_Enum() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); TestOneof2 message = builder.SetFooEnum(TestOneof2.Types.NestedEnum.BAR).Build(); ByteString serialized = message.ToByteString(); TestOneof2 message2 = TestOneof2.ParseFrom(serialized); Assert.IsTrue(message2.HasFooEnum); Assert.AreEqual(message2.FooEnum, TestOneof2.Types.NestedEnum.BAR); }
public void TestOneofSerialization_Primitive() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); TestOneof2 message = builder.SetFooInt(123).Build(); ByteString serialized = message.ToByteString(); TestOneof2 message2 = TestOneof2.ParseFrom(serialized); Assert.IsTrue(message2.HasFooInt); Assert.AreEqual(message2.FooInt, 123); }
public void TestOneofSerialization_Message() { TestOneof2.Builder builder = TestOneof2.CreateBuilder(); TestOneof2 message = builder.SetFooMessage( TestOneof2.Types.NestedMessage.CreateBuilder().SetQuxInt(234).Build()).Build(); ByteString serialized = message.ToByteString(); TestOneof2 message2 = TestOneof2.ParseFrom(serialized); Assert.IsTrue(message2.HasFooMessage); Assert.AreEqual(message2.FooMessage.QuxInt, 234); }