Пример #1
0
        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 }));
        }
Пример #2
0
        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);
        }
 public void DoesNotEnumerateTwiceForEnumList()
 {
     TestAllTypes.Builder b = new TestAllTypes.Builder();
     b.AddRangeRepeatedForeignEnum(new OneTimeEnumerator <ForeignEnum>(ForeignEnum.FOREIGN_BAR));
 }