public void RepeatedAppendRejectsNull() { TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); ForeignMessage foreignMessage = ForeignMessage.CreateBuilder().SetC(12).Build(); TestUtil.AssertArgumentNullException(() => builder.AddRangeRepeatedForeignMessage(new[] { foreignMessage, null })); TestUtil.AssertArgumentNullException(() => builder.AddRangeRepeatedForeignMessage(null)); TestUtil.AssertArgumentNullException(() => builder.AddRangeRepeatedForeignEnum(null)); TestUtil.AssertArgumentNullException(() => builder.AddRangeRepeatedString(new[] { "one", null })); TestUtil.AssertArgumentNullException(() => builder.AddRangeRepeatedBytes(new[] { TestUtil.ToBytes("one"), null })); }
public void SettingRepeatedForeignMessageUsingBuilder() { TestAllTypes message = TestAllTypes.CreateBuilder() // Pass builder for foreign message instance. .AddRepeatedForeignMessage(ForeignMessage.CreateBuilder().SetC(456)) .Build(); TestAllTypes expectedMessage = TestAllTypes.CreateBuilder() // Create expected version passing foreign message instance explicitly. .AddRepeatedForeignMessage(ForeignMessage.CreateBuilder().SetC(456).Build()) .Build(); Assert.AreEqual(expectedMessage, message); }
public void RepeatedAppend() { TestAllTypes.Builder builder = TestAllTypes.CreateBuilder(); builder.AddRangeRepeatedInt32(new int[] { 1, 2, 3, 4 }); builder.AddRangeRepeatedForeignEnum((new ForeignEnum[] { ForeignEnum.FOREIGN_BAZ })); ForeignMessage foreignMessage = ForeignMessage.CreateBuilder().SetC(12).Build(); builder.AddRangeRepeatedForeignMessage(new ForeignMessage[] { foreignMessage }); TestAllTypes message = builder.Build(); TestUtil.AssertEqual(message.RepeatedInt32List, new int[] { 1, 2, 3, 4 }); TestUtil.AssertEqual(message.RepeatedForeignEnumList, new ForeignEnum[] { ForeignEnum.FOREIGN_BAZ }); Assert.AreEqual(1, message.RepeatedForeignMessageCount); Assert.AreEqual(12, message.GetRepeatedForeignMessage(0).C); }